- 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 09:23 AM - edited 10-12-2022 09:24 AM
Let me explain my requirement:
1. experience_Id (string ) is in custom table.
2. x_care3_carear_cus_important_id (reference field) is in kb_knowledge table. And this field is referenced to custom table.
So, when I click on Ui action present in custom table it should open knowledge article form pre populated x_care3_carear_cus_important_id ( Reference field) based on experience_Id on custom table.
Thanks and regards
Virendra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2022 08:25 PM
Hi,
what are the tables in point 1 and point 2?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader