- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 03:55 AM
Which is the best way to Use gs.getUserID method for the LIST type fields in UI actions
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 03:28 AM
You need to add the users to the field, instead of setting the field to the user.
You probably also needs some kind of validation that the user does not yet exist in the list field. The list field is just a list of sys_id's, so you can add the current user's sys_id to the field
(function executeAction(current, previous /*optional*/) {
var mySysId = gs.getUserID();
var exmFieldValues = current.exm_field;
if (!exmFieldValues || exmFieldValues.indexOf(mySysId) === -1) {
if (exmFieldValues) {
current.exm_field += ',' + mySysId;
} else {
current.exm_field = mySysId;
}
current.update();
gs.info('Sys_id added to the field.');
} else {
gs.info('Sys_id already exists in the field.');
}
})(current, previous);
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 04:46 AM
Hi,
Could you please elaborate your query?
Regards,
Karthik Nagaramu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 04:54 AM
Please elaborate. What are you trying to do? What is the UI action you have and what does it need to do with the gs.getUserID method?
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-17-2024 04:58 AM
we made changes to field type from reference to List type
But in UI actions as part the condition we are using ex: current.exm_field== gs.getUserID we are using for reference once we changed to list what is the best way to use method gs.getUserID so it won't impact while we are adding more users to that field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2024 03:28 AM
You need to add the users to the field, instead of setting the field to the user.
You probably also needs some kind of validation that the user does not yet exist in the list field. The list field is just a list of sys_id's, so you can add the current user's sys_id to the field
(function executeAction(current, previous /*optional*/) {
var mySysId = gs.getUserID();
var exmFieldValues = current.exm_field;
if (!exmFieldValues || exmFieldValues.indexOf(mySysId) === -1) {
if (exmFieldValues) {
current.exm_field += ',' + mySysId;
} else {
current.exm_field = mySysId;
}
current.update();
gs.info('Sys_id added to the field.');
} else {
gs.info('Sys_id already exists in the field.');
}
})(current, previous);
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark