- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2023 10:03 AM
Hi All,
My requirement is in CMS table Mapping when i am doing field mappings ..so ,writing a script for getting a field value from Impact table to do field mapping with Knowledge table(to populate the 'Opened_by'(userfield) User first group(from the group list of Opened_by User) in Knowledge group field after doing a click on "Create Knowledge Error" button ) .
"Create Knowledge Error" (Button) functionality :
When we click on this button in Impact Form , it will redirect to Create Form of Knowledge article .
Need :
After clicking button , Knowledge article form should have auto-populated values form impact table.
Issue :
In below code ..when i am calling 'opened_by' getUserID() value in encodedQuery() , code is not working ..Could you help me here what i needs to correct here .
[Note:below script writing on 'u_impact' Table]
(function(source))
{
var oc = gs.getUserID('current.parent.opened_by');
var grUser = new GlideRecord('sys_user_grmember');
grUser.addEncodedQuery('active.group=true^user='+source.oc);
grUser.setLimit(1);
grUser.query();
var count = grUser.getRowCount();
grUser.next();
if(count==1)
return grUser.getValue('group');
else{
return '' ;
}
}
)
I suspect there is an error in syntax in line no :5 (when i tried in backgroud script it's not getting value from opened_by field )
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2023 11:40 AM
Hi Emir ,
Thanks for your efforts ...When i am debugging the code just now i found a small mistake in below code
actually it should give like
var oc = current.opened_by;
it should not be like
var oc = gs.getUserID('current.parent.opened_by');
Note:in 2 nd line i should not give current.parent ....it should be current.opened_by
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2023 11:01 AM
You have a cusotm Impact table so let's break that down too:
What form are you looking when this code runs?
Is the Parent field populated for this record?
Does the parent have opened by value?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2023 11:06 AM
also can you validate the opened_by field name is opened_by and not u_opened_by since this seems to be custom....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2023 11:40 AM
Hi Emir ,
Thanks for your efforts ...When i am debugging the code just now i found a small mistake in below code
actually it should give like
var oc = current.opened_by;
it should not be like
var oc = gs.getUserID('current.parent.opened_by');
Note:in 2 nd line i should not give current.parent ....it should be current.opened_by