Updating Requested For isn't working for our Record Producer

ewilks
Giga Expert

According to this wiki article (Record Producer - ServiceNow Wiki), if a record producer has a variable of the same name as a field in the table the record producer populates then the field should be updated by the value in the Variable.   In section 2.1   of this article, it reads "Create a variable on the record producer with the same name as the field in the target record. For example, a variable named caller_id on a Create a New Incident record producer populates the caller_id field on the new incident record. Use a variable type that corresponds to the field type."

Well, in our record producer that populates the "Request [sc_request]"   table, we have a variable named "requested_for" which is part of a variable set named "Requested for".   However, if a user updates the requested for field with a user other than themselves prior to submitting the Record producer, the requested_for on the sc_request table is still the person who opens the request.    

So, what should I do (and where) to make the requested_for field on the sc_request table   is set to the value from the "requested_for" variable on my record producer.   By the way, it's the same with any of my catalog items; where the requested_for variable doesn't update the requested_for field on the sc_request table.

Thanks

1 REPLY 1

randrews
Tera Guru

on all but the record producers it is being set by the requested for on the cart... to fix the non record producers create an on change client script to set the cart requested for to the requested for on the variables whenevr the requested for variable is changed... this behavior is because the cart always requests to g_user



as far as why your record producers are working.. i am bumfuzzled that is exactly what we do..include the variable set that has requested_for as a variable.. without the on change client script <no cart on a record producer> and it works fine.




-----------script----------------------


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



    if (isLoading){return;}


    if (newValue){


          var gr = new GlideRecord('sc_cart');


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


          gr.query();


          gr.next();


          gr.requested_for = newValue;


          gr.update();


    }


}