Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

How to pass field value from UI action to another form field value

Community Alums
Not applicable

Hi Team,

 

I have a requirement wherein when we click on a UI action it should open another form and copy the value in Contact field which is a reference field from current form to the new form of same field type.

Below URL is getting opened which is a new record creation form:

 

https://instance.com/sn_customerservice_bulkupdatecontactrelationship.do?sys_id=-1&sys_is_list=true&...

 

The redirecting is happening fine,its the copying of value of contact field from the current form to the same field type on new form I need to achieve.

Can you assist?

4 REPLIES 4

Service_RNow
Mega Sage

Hi @Community Alums 

follow this link

https://www.servicenow.com/community/developer-forum/copying-field-within-ui-action/m-p/2808324

 

Please mark reply as Helpful/Correct, if applicable. Thanks!

 

Mark Manders
Mega Patron

Can you share the code you are using in the ui action?

Something like this should just work:

createCopy();

function createCopy() {
var newRecord = new GlideRecord("your_table");
newRecord.initialize();
newRecrod.contact = current.contact;
newRecord.insert();

Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Community Alums
Not applicable

Actually I do not need to insert record after routing to a new Page. I need to just copy the value after I click on UI Action.Below is the code wherein I am routing to the New record creation page. Now my requirement is once its routed to below URL as mentioned, it should copy the field value.

Say I am on Form A with a field called as 'Contact'. Once I click on UI action, it should copy the field value of 'contact' from Form A to same field type on 'Form B' .The new page which gets opened below is the New record creation page with some fields and the interested field is 'contact'

 

 

function route() {
    var contact = g_form.getValue('contact');
    var url = 'sn_customerservice_bulkupdatecontactrelationship.do?sysparm_u_contact='+contact;
   g_navigation.openPopup(url);
}

Community Alums
Not applicable

Thanks My issue is resolved by updating URL as 

var url = 'sn_customerservice_bulkupdatecontactrelationship.do?sys_id=-1&sysparm_query=u_contact='+contact;