User Tools

Site Tools


start

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
start [12/30/2024 06:07] – [My Code] johnsonjohnstart [12/30/2024 07:02] (current) johnsonjohn
Line 34: Line 34:
 </code> </code>
  
 +===Assign To Me Button=== 
 +<code>
 +//Credit to: https://servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/
 +
 +//Onclick: runClientCode();
 +//Condition: gs.hasRole('itil')&& gs.getUser().isMemberOf(current.assignment_group.toString())
 +
 +//Client-side 'onclick' function
 +function runClientCode(){
 + g_form.setMandatory("assigned_to",false);
 +//Call the UI Action and skip the 'onclick' function
 +gsftSubmit(null, g_form.getFormElement(), 'assignToMe'); //MUST call the 'Action name' set in this UI Action
 +}//Code that runs without 'onclick'
 +//Ensure call to server-side function with no browser errors
 +if(typeof window == 'undefined')
 +runBusRuleCode();
 +
 +//Server-side function
 +function runBusRuleCode(){
 + current.assigned_to = gs.getUserID();
 + current.update();
 + action.setRedirectURL(current);
 +}
 +
 +</code>
 ---- ----
  
start.1735567671.txt.gz · Last modified: 12/30/2024 06:07 by johnsonjohn

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki