- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 03:46 AM
Hi,
There is a choice field named 'project' and the choice values are A,B and C and I want to display one value ie A of this choice field for the condition 'logged in users location and job title'. (Here only A value of this choice field.
Please can anyone suggest me how we can implement this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 04:27 AM
Hi
Please write a Display Business Rule on the Table where these fields are present and use the script as below which will check logged in User Location and Job Title as below:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var loggedUser = gs.getUserID();
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id',loggedUser);
gr.query();
if(gr.next()){
g_scratchpad.Location = gr.getDisplayValue('location');
g_scratchpad.Title = gr.getDisplayValue('title');
}
})(current, previous);
Now write a On Load Client Script on the same table and use the script as below:
function onLoad() {
//Type appropriate comment here, and begin script below
if (g_scratchpad.Location == 'Your value to check' && g_scratchpad.Title == 'Your value to check') {
g_form.clearOptions('Field Name where choices are there');
g_form.addOption('FieldName', 'chocieValue', 'ChocieLabel');
} else {
g_form.clearOptions('Field Name where choices are there');
g_form.addOption('FieldName', 'chocieValue1', 'ChocieLabel1');
g_form.addOption('FieldName', 'chocieValue2', 'ChocieLabel2');
}
}
Hope this helps. Please mark the answer as correct/helpful based on impact.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2022 04:47 AM
Sure Ulka. If you have a follow up query do let me know.
Else please mark my answer as correct and close this thread for others.
Regards,
Shloke
Regards,
Shloke
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-28-2022 12:33 AM
Hi Shloke,
Now the requirement is changed such that instead of logged in user, we have to fetch the value of location and jobtitle for the "Subject Person" field (This is a reference field for sys_user table like caller field for the incident form) which is on the HR Situation case Management form.
Please could you assist me for the same.