How to Override Default for Requested For Field

ajlabate
Kilo Expert

The Requested for field is always set to whoever is creating the request (the person presently logged in).   I'm trying to make it something different and all my attempts have failed.   Ultimately, I'd like it to be the name of the person that is entered into the Variable (Requested for).   I checked the dictionary for the field and saw that it had a default value as javascript:gs.getUserID()     I removed this default value but the field gets set anyway.   I tried to set it in the beginning of the workflow with a Run Script activity to the variable entry submitted by the user but that does nothing.   No matter what I do, the field is always set to the person entering the request.   I need that person to be able to designate someone else as the requested for person.   Any ideas?

 

This is the script in the workflow:

var reqRecord = current.request.getRefRecord();

reqRecord.requested_for = current.variable_pool.requested_for;

1 ACCEPTED SOLUTION

yes sir.. just replace the entire script with the below and it should work like magic.



___________________




function onChange(control, oldValue, newValue, isLoading) {


   


    if (newValue){


          var gr = new GlideRecord('sc_cart');


          gr.addQuery('user', g_user.userID);


          gr.query();


          gr.next();


          gr.requested_for = newValue;


          gr.update();


    }


}


View solution in original post

55 REPLIES 55

In a similar situation I had a before business rule on sc_req_item on insert and update


and never had any issues.-



current.request.requested_for.setValue(current.variables.RequestedFor);


sc_cart.requested_for.setValue(current.variables.RequestedFor);


ok impersonate someone else and see if it is setting it correctly on the cart or not...



if it is getting set wrong on the cart... look at the acls for the cart requested for.... if it is right on the cart but wrong on the request.. look at the br's / client scripts in the request.


Doug, when I do the two step process, the requested for field is not being updated for the non-admin people (but it is for me). I don't have many ACLs set. How do I see if there is an ACL for the cart?



>>> Doug Andrews <community-no-reply@servicenow.com> 10/13/2014 9:55 AM >>>




( https://community.servicenow.com/?et=watches.email.thread )



How to Override Default for Requested For Field


reply from Doug Andrews ( https://community.servicenow.com/people/randrews?et=watches.email.thread ) in Support - View the full discussion ( https://community.servicenow.com/message/729962?et=watches.email.thread#729962 )


ok impersonate someone else and see if it is setting it correctly on the cart or not...



if it is getting set wrong on the cart... look at the acls for the cart requested for.... if it is right on the cart but wrong on the request.. look at the br's / client scripts in the request.



Reply to this message by going to ServiceNow ( https://community.servicenow.com/message/729962?et=watches.email.thread#729962 )


Start a new discussion in Support at ServiceNow ( https://community.servicenow.com/choose-container.jspa?contentType=1&containerType=14&container=2008&et=watches.email.thread )


Following How to Override Default for Requested For Field ( https://community.servicenow.com/message/729962?et=watches.email.thread#729962 ) in these streams: Inbox



( https://www.facebook.com/servicenow ) ( https://twitter.com/servicenow ) ( http://www.linkedin.com/company/servicenow ) ( http://www.servicenow.com )



"This electronic mail message contains information which may be confidential, privileged and protected from further disclosure. Such information relates to and is used for all purposes outlined in the statutes below, including Peer Review, Performance Improvement, Quality Assurance and Claims Management and Handling functions and/or Attorney-Client Communications. It is being produced within the scope of all Georgia and Federal laws governing record confidentiality, including (but not limited to) Official Code of Georgia Annotated Sections 31-7-15; 31-7-130; 31-7-131; 31-7-132; 31-7-133; 31-7-140; 31-7-143.


If you are not the intended recipient, please be aware that any disclosure, photocopying, distribution or use of the contents of the received information is prohibited. If you have received this e-mail in error, please reply to the sender immediately and permanently delete this message and all copies of it. Thank you.



Communication of electronic protected health information (ePHI) is protected under the Health Insurance Portability and Accountability Act (HIPAA) Act of 1996. Electronic mail (e-mail) communication is not encrypted or secure. The HIPAA Security Rule allows for patients to initiate communication of personal health information over this medium and for providers to respond accordingly with the understanding that privacy of communication is not guaranteed."


here's the error from the sc_cart (I think):



10:13:52.762: TIME = 0:00:00.000 PATH = record/sc_cart.current_crumb_history/write RULE = ((((hasRole() AND script=var answer = true; answer;)) SEQ ((hasRole() AND script=gs.hasRole('admin') || gs.getProperty('glide.sm.default_mode') == 'allow') OR (hasRole() AND script=var ra = false; if (root_rule.substring(0,7)=='var__m_' || root_rule == 'wf_workflow.vars') { ra = gs.getUser().hasRole('workflow_creator') || gs.getUser().hasRole('normalizer'); } ra; ))) AND (((hasRole() AND script=var answer = true; answer;)))) RC = false




I don't know how to find the source so I can change it.


it doesn't go on the sc_request table.. it goes in the item you are creating in the client script section for that item.