Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

only display ui action if current user is the requested for user

sigmachiuta
Kilo Guru

I am trying to create a UI action condition that the user that should see the UI action is the person that has requested the item.   Would this work in the condition?

current.requested_for == gs.getUser().    

1 ACCEPTED SOLUTION

As you seem to be trying to combine client-side and server-side methods in a single script, you need to use a special technique that is very well explained by Mark Stanger in the following blog post:


Client & Server Code in One UI Action - ServiceNow Guru


View solution in original post

6 REPLIES 6

Ah! ok yea that worked.   the only problem I have is that the state field is being driven by workflow and even though a item is cancelled the workflow state is still in a pending state.   How can I override the workflow state on a cancellation of a workflow/ item?   In my cart I am still seeing the workflow state from the workflow.



function checkCancel(){


  if(g_form.getValue('u_cancel') == ''){


  alert('Please provide a Cancel reason.');


  g_form.setMandatory('u_cancel',true);



  }


else {


  gsftSubmit(null, g_form.getFormElement(), 'hr_cancel');


  }


}


gs.addInfoMessage('The current item request has been cancelled.');


  current.state= 4;


  current.stage = 'Request Cancelled';



  //get workflow helper


  var workflow = new Workflow();


  //cancel all the workflows, where current is a task record with a workflow context


  workflow.cancel(current);


  gs.addInfoMessage(gs.getMessage("Workflows for {0} have been cancelled", current.getDisplayValue()));


  current.update();


Ill break this question into another thread because I think its a little off target for this thread.