Service portal: How to set field values while creating a new record

SanjivMeher
Kilo Patron
Kilo Patron

Hi Experts,

I have created a button which calls the Form Widget in Service Portal. I am able to pass the table name, sys_id as -1 and view to open a new record.

Now I also I want to pre-populate field fields when i click on the button. How can I pass the other field values to form widget?

If form widget is not an option, what should be done?


Please mark this response as correct or helpful if it assisted you with your question.
1 ACCEPTED SOLUTION

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I don't think the form widget accepts query parameters for populating fields like the oob form view does. You might try a client script on the form that checks to see if you're in service portal, then grabs the url parameters and sets the fields.


View solution in original post

4 REPLIES 4

Brad Tilton
ServiceNow Employee
ServiceNow Employee

I don't think the form widget accepts query parameters for populating fields like the oob form view does. You might try a client script on the form that checks to see if you're in service portal, then grabs the url parameters and sets the fields.


Thats my last option.


There is a line in form widget


result = $sp.saveRecord(input.table, input.sys_id, input._fields);



Do you know, what does input._fields signifies? I couldn't find any definition for $sp.saveRecord



Please mark this response as correct or helpful if it assisted you with your question.

I ended up using a client script. Thanks Brad



Please mark this response as correct or helpful if it assisted you with your question.

tantony
Mega Guru

You will have to clone OOB form widget. If you are opening cloned form widget on a spModal you can pass the form fields and values  in the 'shared' parameter of spModal.open() as documented here. The 'shared' JSON object is accessible in the embedded cloned form widget's client script