setting variables in client script to readonly/hidden after record is created

sammarcow
Mega Expert

I have a records created through a catalog item, and want the variables following record creation to be readonly.       I created a client script on table sc_req_item with simply alert('click') with no conditions.     The client script only produces the alert when I click "New" for table sc_req_item, not when I load an existing sc_req_item with a variables pool populated.       How do I get these to execute on existing records?

Onload client scripts against table sc_req_item:

function onLoad() {

  alert('click'); //runs only on new item.    

}

1 ACCEPTED SOLUTION

Community Alums
Not applicable

William,



Look at your client script; you should see some checkboxes toward the top. Ensure that "Applies on Requested Items" is checked. This should solve your problem.



However,



I would use UI policies to do what you're attempting. Just create a UI policy with "Applies on Catalog Items" unchecked, and "Applies on Requested items" checked, and then create a UI Policy Action for each variable.


View solution in original post

14 REPLIES 14

Community Alums
Not applicable

Is the goal to allow addition of manual approvers?



If your workflow has approval activities in it, then you can accomplish this without custom ui macros. You should be able to add a Manual Approvals workflow activity to the workflow, and enable the functionality I'm seeing in your screenshot. It would then appear on it's own tab as a related list.



You can also use the workflow to automatically add a user specified by the person who submitted the request as a manual approver.



Does this sound like what you're trying to do?


We need the ability to intervene at any point in time of the approval process.   Members of a particular group can intervene, and may not be the original requestors.   The functionality is complete, and correct me if I am wrong but this cannot be done with a manual approval workflow activity because only the requestor could initiate the manual approval.    


Community Alums
Not applicable

I'm a bit hazy on the how, because I wasn't the developer who led this particular project, but I know that currently, our change module allows both the requester and members of the change management group to which the ticket has been assigned to add manual approvals, so it's definitely possible for people other than the requester to add manual approvals.



I think it would be as simple as editing the conditions under which the "edit" button on that related list is made available. (the UI action).



If you just want to use what you've already got, you can add your UI macro to the form via a formatter:



Creating a Formatter - ServiceNow Wiki



Once you do this, you can add it to the form like any other field by configuring the form layout.


Abhinay Erra
Giga Sage

Exactly that is why I am confused how your question was answered when it did not fix anything.



Open your browser console and load the form again and see if you can find any errors


Thank you I see how that could have been confusing.