- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 03:25 AM
Hi Everyone,
I have requirement to populate reference field using UI action.
Ui Action:
var mName = g_form.getValue('instruct_model_name');
var mUrl = g_form.getValue('instruct_model_url');
var nDesc = g_form.getValue('model_description');
var ex_id = g_form.getValue('experience_id'); // string field present on table 1
var link = '<a href= ' + mUrl + ' target=_blank>Click here to launch</a>';
g_navigation.open("/kb_knowledge?sys_id=-1&sysparm_query=short_description= " + mName +
"^x_care3_carear_cus_important_id =" + ex_id + // [ x_care3_carear_cus_important_id is reference field present on table 2]
"^text =" + '<h1> <strong> ' + mName + ' </strong></h1> ' +
'<br/>' + '<h2>' + nDesc + '</h2> ' +
'<br/>' + '<h2>' + link + '</h2> ' , "_blank");
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 05:44 AM
update as this
var mName = g_form.getValue('instruct_model_name');
var mUrl = g_form.getValue('instruct_model_url');
var nDesc = g_form.getValue('model_description');
var ex_id = g_form.getValue('experience_id'); // string field present on table 1
// then query and get sysId
var rec = new GlideRecord("table"); // give here the table which is referred by x_care3_carear_cus_important_id field
rec.addQuery("u_name", ex_id); // give here the field name which holds data which you get in experience_id field
rec.query();
rec.next();
var link = '<a href= ' + mUrl + ' target=_blank>Click here to launch</a>';
g_navigation.open("/kb_knowledge?sys_id=-1&sysparm_query=short_description= " + mName +
"^x_care3_carear_cus_important_id =" + rec.getUniqueValue() + // [ x_care3_carear_cus_important_id is reference field present on table 2]
"^text =" + '<h1> <strong> ' + mName + ' </strong></h1> ' +
'<br/>' + '<h2>' + nDesc + '</h2> ' +
'<br/>' + '<h2>' + link + '</h2> ' , "_blank");
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 05:02 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 05:44 AM
update as this
var mName = g_form.getValue('instruct_model_name');
var mUrl = g_form.getValue('instruct_model_url');
var nDesc = g_form.getValue('model_description');
var ex_id = g_form.getValue('experience_id'); // string field present on table 1
// then query and get sysId
var rec = new GlideRecord("table"); // give here the table which is referred by x_care3_carear_cus_important_id field
rec.addQuery("u_name", ex_id); // give here the field name which holds data which you get in experience_id field
rec.query();
rec.next();
var link = '<a href= ' + mUrl + ' target=_blank>Click here to launch</a>';
g_navigation.open("/kb_knowledge?sys_id=-1&sysparm_query=short_description= " + mName +
"^x_care3_carear_cus_important_id =" + rec.getUniqueValue() + // [ x_care3_carear_cus_important_id is reference field present on table 2]
"^text =" + '<h1> <strong> ' + mName + ' </strong></h1> ' +
'<br/>' + '<h2>' + nDesc + '</h2> ' +
'<br/>' + '<h2>' + link + '</h2> ' , "_blank");
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 06:33 AM
What do you mean by u_name in line rec.addQuery("u_name", ex_id); . experience_id is field which stores value on table 1.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 07:50 AM
Hi,
experience_id stores some string.
You need to decide against which field of the table you need to query to get the record
So that field you have to use in place of u_name
I just gave an example
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader