- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 04:47 AM - edited 05-30-2024 06:20 AM
Hello
I have a question regarding Business Rule Script.
When the caller is Abraham Lincoln, I want Channel to be populated as Self-service. (As you can see in the image below)
Here is the script but it is not working.
(function executeRule(current, previous /*null when async*/) {
// Ensure the caller ID is present
if (current.caller_id) {
// Get the caller's record from the sys_user table
var caller = new GlideRecord('sys_user');
if (caller.get(current.caller_id)) {
// Check if the caller's name is Abraham Lincoln
if (caller.name == 'Abraham Lincoln') {
// Set the channel to Self Service
current.channel = 'self-service';
}
}
}
})(current, previous);
I appreciate any help.
TIA 😃
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 08:02 AM
Hi @AysenurU ,
You can write onChange client script and populate the Channel value,
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var caller = g_form.getReference('caller_id', currentUser1);
}
function currentUser1(caller){
if(caller.name == 'Abraham Lincoln'){
g_form.setValue('contact_type','self-service');
}
}
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 05:00 AM
Hi @AysenurU ,
Have you written this code in onChange Client Script or some Business Rule.
I see, you have used the current object, means its business rule. If that is the case, you can set this value without any script code.
First you decide, are you looking for client side change or server side ( means on/after save ).
For client side , write client script on incident table for caller column.
For server side, update the BR with below.
This is BR [ insert ] on Incident table with condition check for caller.
Use Action tab for setting channel value
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 05:37 AM - edited 05-30-2024 06:09 AM
Hey Ashish
First I tried to create a Business role without any scripts.
But it is not changing or updating anything on my Incident form😔
Then I wanted to try Client script.
However, it did not work either.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 05:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 08:02 AM
Hi @AysenurU ,
You can write onChange client script and populate the Channel value,
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var caller = g_form.getReference('caller_id', currentUser1);
}
function currentUser1(caller){
if(caller.name == 'Abraham Lincoln'){
g_form.setValue('contact_type','self-service');
}
}
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang