Incident field displays "-" after clicking on UI action in SOW before populating the actual value

kandulek
Tera Contributor

Hi All,

 

We have a UI Action that pauses the incident record and sets the value of Pending Reason field to '30'. In the backend it works as expected. However, in the Service Operations Workspace, when pausing the ticket, the Pending Reason is blank (displaying "-" as in the screenshot below). It is greyed out and after saving populating the correct value, but it might be confusing for agents.

 

kandulek_0-1755024827565.png

 

Piece of UI action Workspace script:

 function onClick() {

     try {
         var ga = new GlideAjax('example_ajax');
         ga.addParam('sysparm_name', 'getPendingData');
         ga.addParam('sysparm_incidentID', g_form.getUniqueValue());

         ga.getXMLAnswer(function(response) {
             var result = JSON.parse(response);

             if (result.apply) {
                 g_form.setValue("hold_reason", "30");
                 g_form.setValue("due_date", result.due_date_display);
             } else {
                 if (g_form.getValue("u_type") === "complaint") {
                     g_form.setValue("hold_reason", 20);
                 }
             }

             // Call the UI Action and skip the "onclick" function
             g_form.submit("pause_incident"); // MUST call the "Action name" set in this UI Action
         });
     } catch (oErrMsg) {
         alert("UI Action:Pause Incident; function: pauseIncident. Error Message received from Try/Catch: " + oErrMsg);
     }
 }

 

How could I show the field on the form in SOW only when it is already populated with the correct value?

 

I would be grateful for any hints.

 

Best regards!

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@kandulek 

is it going inside that IF and setting the value?

seems some script is running in SOW which is clearing that again?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader