Define field as read-only in after change

Hi all,

Situation: We want to make the scheduled start and end time of a normal change read only after the change has been approved for deployment so that users can't change the start or end time of their change anymore after it has been approved for deployment.

I tested several solutions to make it as compact as possible, so 1 business rule for scheduled start and 1 business rule for scheduled end:

I tried:

${current_update.PhaseId.IsChanged && current_update.PhaseId.NewValue == 'Execute'} 
${current_update.PhaseId.IsChanged && entity.PhaseId == 'Execute'}

And later on I would add the other phases to, but just this to test with. So in the end it would be something like:

${current_update.PhaseId.IsChanged && (entity.PhaseId == 'Execute' || entity.PhaseId == 'CMDBUpdate' || entity.PhaseId == 'Review' || entity.PhaseId == 'Close' || entity.PhaseId == 'Abandon')}



But the rules are not working, the fields stay available after reaching 1 of the phases. Is my way of thinking wrong? 

Now I can work around this and just create a rendering forms rule for each Phase, but then I have more rules:



Any suggestions?

  • Verified Answer

    +1  

    Hello

    I think your condition should be the reverse:

    current_update.PhaseId.IsChanged == false

    When the approval is complete, you still need to allow the record to transition into the new phase. Once the transition is complete, you lock it.

    Best regards,

    Brindusa

  • 0 in reply to   

    Hi Brindusa,

    Somehow I missed your update...

    I do not really understand what you mean, basically what we want is that when we see the phase change, and it is now in for example the execute fase, we want to disable some fields so they can no longer be editted. Is this what you are suggesting?

    ${current_update.PhaseId.IsChanged == false && current_update.PhaseId.NewValue == 'Execute'} ?

    I could not get it to work with my earlier suggestion so what I did was the following:

    Go to Change -> Normal -> Rendering Forms ->

    If ${entity.PhaseId == 'ApproveDeployment' || entity.PhaseId == 'Execute' || entity.PhaseId == 'Backout' || entity.PhaseId == 'CMDBUpdate' || entity.PhaseId == 'Review' || entity.PhaseId == 'Close' || entity.PhaseId == 'Abandon'}

    Disable scheduled start

    And I repeated this for all the fields.

  • Verified Answer

    +1   in reply to 

    Hello

    The only change I made to your original expression was to "reverse" the first condition to check for false rather than true on PhaseId change:

    ${current_update.PhaseId.IsChanged == false && (entity.PhaseId == 'Execute' || entity.PhaseId == 'CMDBUpdate' || entity.PhaseId == 'Review' || entity.PhaseId == 'Close' || entity.PhaseId == 'Abandon')}

    The only change I made to your original expression was to "reverse" the first condition to check for false rather than true on PhaseId change. I tested with both transitioning into one of the phases and trying to modify the field once in one of the listed phases and it seems to work.

    As a note, you could as well switch and use the Restrict/allow editing of fields rule. The rule functions both as a rendering rule and as a validation rule (in the user interface it appears under Rendering rules). It restricts or allows editing of selected fields for all actions, UI-based, backend process-based, or API-based. 

    Best regards,

    Brindusa

  • 0 in reply to   

    Hi Brindusa,

    Yes thank you, we ended up going for the Restrict/allow editing of fields because that also does a validation on mass update. For example disable field still leaves the option to do a mass update and still change the field. Also the Restrict/allow editing of fields rule has multple field options so you only need 1 rule for multiple fields instead of 1 rule each field so we went that route: