Home General Discussion

Cireson Portal - Form Customization - Set Field to Required based on Work Item Status

AJ_WittenbrinkAJ_Wittenbrink Customer Adept IT Monkey ✭✭
Is there any way to set a field to required based on Work Item Status.

I can set a field as required by adding "required = true," to most fields.  However, I want to set a field to required when the form status changes to Completed, or Failed.

My use case is an Incident or Release record that failed.  While they are suppsoed to enter in a reason why to it failed, there are many that don't.  So i want to force the field to be required when the status (the enumerated value) is in a closing state.

Answers

  • Brett_MoffettBrett_Moffett Cireson PACE Super IT Monkey ✭✭✭✭✭
    This type of solution would assume that the analyst opens the WI that is completed or failed and tries to save it. Only then would a required field pop up.
    Usually at that point, most analysts (That I've worked with anyhow) would just cancel the save so they don't have to comment.

    A better solution would be a nag that they can't ignore.

    Maybe an e-mail reminder that bugs them every day they do not enter the required detail, or a custom form that pops up on the portal and forces them to make updates before they can do anything else.

    I've done a solution similar to the e-mail one. People quickly learnt to make sure they entered the details in the WI. However, I feel the second option might be a little more polished and professional.
  • AJ_WittenbrinkAJ_Wittenbrink Customer Adept IT Monkey ✭✭
    Brett,

    I don't think this would be when the analyst open.  This is when the analyst changes the status.  Which would be after the open and change the status.  At that time, client side script to change the required property to true.

    So this would prevent them from saving it with that new status unless something is filled in that field.
  • james_kleinschnitzjames_kleinschnitz Cireson Dev, Product Owner Advanced IT Monkey ✭✭✭
    You will need to add a custom task that is trigger on a status change:
    https://support.cireson.com/KnowledgeBase/View/1188#/

    I quickly put this together but did not fully test it:
    <br><div>app.custom.formTasks.add('Incident', null, function (formObj, viewModel) {
    
    </div><div>&nbsp; &nbsp; formObj.boundChange("Status.name",function () {
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp; //do whatever you need here
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp; //you have access to the viewModel from here as well
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp; if (viewModel.Status.Id === "2b8830b6-59f0-f574-9c2a-f4b4682f1681") {
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('[name="Title"]').attr( 'required');
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $('[for="Title"]').append( '<span>(required)</span');
    
    </div><div>&nbsp; &nbsp; &nbsp; &nbsp; }
    
    </div><div>&nbsp; &nbsp; });
    
    </div><div>});</div>
    In this example, if the IR status is changed to resolved (2b8830b6-59f0-f574-9c2a-f4b4682f1681) I set the Title text field to required and change the label.  

    I hope this helps.

    Thanks
  • AJ_WittenbrinkAJ_Wittenbrink Customer Adept IT Monkey ✭✭
    James thanks for this.  I recently updated and started to take a look at how Cireson does it with Asset management forms, but this this clean and simple code.  I will test it out and let you know!
  • Jeff_LandersJeff_Landers Customer IT Monkey ✭
    edited February 2019
    @james_kleinschnitz

    I have been trying to get this to work but I lack some understanding.   
    I am trying to do this

     If the status that the SR is being changed TO is Completed and the supportgroup is blank, null, whatever
    then pop the alert and make the analyst fill it out.

    I see lots of posts for folks trying to do this but no definitive solution. 
    We want to be able to transfer the ticket with the analyst, support, group, area, blank until it is being completed
    Is this anywhere close because I can't get it to work.
    Thank you
    Jeff

    app.custom.formTasks.add('ServiceRequest', null, function (formObj, viewModel) {

        formObj.boundChange("Status.name",function () {

            //do whatever you need here
         alert("Support Group is Required!");
            //you have access to the viewModel from here as well
          // if the status is Completed  
           if (viewModel.Status.Id === "59393f48-d85f-fa6d-2ebe-dcff395d7ed1" and pageform.viewmodel.supportgroup === "" ) {
       alert("Support Group is Required!");
               $('[name="SupportGroup"]').attr( 'required');

              $('[for="SupportGroup"]').append( '<span>(required)</span');

            }

        });

    });
  • james_kleinschnitzjames_kleinschnitz Cireson Dev, Product Owner Advanced IT Monkey ✭✭✭
    @Jeff_Landers

    I think your check for supportgroup being empty maybe a little too simplistic, try this out:

    ));
               
                $('[data-role="SupportGroup"]').attr('required', true);
            }
    
        });
    
    });
    
    
    
    app.custom.formTasks.add('ServiceRequest', null, function (formObj, viewModel) {
    
        formObj.boundChange("Status",function () {
    
            //do whatever you need here
            //you have access to the viewModel from here as well
            // if the status is Completed  
    
            var srCompletedStatus = "b026fdfd-89bd-490b-e1fd-a599c78d440f"; //completed status id
            var isSupportGroupEmpty = _.isUndefined(viewModel.SupportGroup) || _.isUndefined(viewModel.SupportGroup.Id) || _.isNull(viewModel.SupportGroup.Id);
    
            if (viewModel.Status.Id === srCompletedStatus && isSupportGroupEmpty) {
                alert("Support Group is Required!");
                $('[name="SupportGroup"]').attr('required', true);
                $('[for="SupportGroup"]').append('(required)
  • Jeff_LandersJeff_Landers Customer IT Monkey ✭
    edited March 2019

    @james_kleinschnitz

    You are going to make a log of people very happy.    I have it working but it will need a few tweaks to keep the Chrome users honest since they can Cancel the Leave the Page and still complete with blank fields. Another question.    Can I get to the Assigned to user and the Area in the viewmodel because I don't see it.  I will post the complete code when done.   Thank you so much.

    var isareaEmpty  = _.isUndefined(viewmodel.Area) || _.isNull(viewModel.Area);
     var isAssignedToEmpty = _.isUndefined(viewModel.assignedtouser)

  • james_kleinschnitzjames_kleinschnitz Cireson Dev, Product Owner Advanced IT Monkey ✭✭✭
    Assigned To is: viewModel.AssignedWorkItem
    and Area is: viewModel.Area
Sign In or Register to comment.