- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-23-2021 07:02 AM
Hi All,
Edit: This works in Platform UI as expected( when I put code in script section), but in Workspace UI I am able to run only Server Side script and client side script is skipped.
I am creating One UI action which should execute following actions when clicked from Agent Workspace Incident form:
1. Create and Interaction
2. Open a teams chat using deep link.
I am able to run these two scripts separately with two UI actions, but when I try to combine both of them in one UI action, I am not able to do it..
Not sure how exactly can I put this together, I tried it this way but when I run the action from Workspace, I get error as 'Failed to execute UI action, please contact your system administrator'
Please find my Ui action details and code below:
UI action name: start_chat
Active: true
client: true
Onclick: runClientSideCode();
Workspace Form button: true
Workspace Client Script: //I have wrote the script here as I was not able to execute in on workspace when written in Script section too
if(typeof window == 'undefined')
{
runServerSideCode();
}
function runClientSideCode()//added this function in onClick field of Ui action
{
//script to open Teams chat
var prefix = 'https://teams.microsoft.com/l/chat/0/0?users=';
var ref = g_form.getReference('caller_id', getEmail);
var inc_number=g_form.getValue('number');
var inc_Sd= g_form.getValue('short_description');
function getEmail(ref)
{//Callback function
var email = ref.getValue('email');
var firstname=ref.getValue('first_name');
var subject = '&message=Hi '+ firstname + ','+' this is regarding your Incident ' + inc_number + ' : '+inc_Sd;
var url = prefix + email + subject;
top.window.open(url);
}
gsftSubmit(null, g_form.getFormElement(), "start_chat"); //this is my UI action name
}
function runServerSideCode()
{
//Script to create interaction
var incGr = new GlideRecord('interaction');
incGr.newRecord();
incGr.setValue('opened_for', current.getValue('caller_id'));
incGr.setValue('short_description', current.short_description);
incGr.setValue('direction', 'Outbound');
incGr.insert();
action.openGlideRecord(incGr);
}
Kindly suggest on how can we get this working.
Thanks in advance.
Ganesh
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-24-2021 03:15 AM
This is working now.
Initially I was using the gsftsubmit to call UI action but was getting error in workspace while executing UI action
now I have Script to create Interaction in 'Script' field of UI action and script to open teams chat in Workspace Client script field , from where I am calling the UI action using g_from.submit();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-23-2021 10:11 AM
1. Please use the insert/edit code sample function in the editor when you need to add code to a question.
2. You need to actually call the function runClientSideCode(). You define the function, but you never invoke it. You should have something like the following (inserted using the icon:
if (typeof window == 'undefined') {
runServerSideCode();
} else {
runClientSideCode();
}
...
Frank
Please mark this answer as helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-23-2021 11:49 AM
Make sure the Isolate script check box is 'off' on the script. Also re-order the script in the following way.
Submit the form after getting the email in the reference.
function runClientSideCode() //added this function in onClick field of Ui action
{
//script to open Teams chat
var prefix = 'https://teams.microsoft.com/l/chat/0/0?users=';
var ref = g_form.getReference('caller_id', getEmail);
var inc_number = g_form.getValue('number');
var inc_Sd = g_form.getValue('short_description');
function getEmail(ref) { //Callback function
var email = ref.getValue('email');
var firstname = ref.getValue('first_name');
var subject = '&message=Hi ' + firstname + ',' + ' this is regarding your Incident ' + inc_number + ' : ' + inc_Sd;
var url = prefix + email + subject;
top.window.open(url);
gsftSubmit(null, g_form.getFormElement(), "start_chat"); //this is my UI action name. Submit the form after getting the email and opening a window.
}
}
if (typeof window == 'undefined') {
runServerSideCode();
}
function runServerSideCode() {
//Script to create interaction
var incGr = new GlideRecord('interaction');
incGr.newRecord();
incGr.setValue('opened_for', current.getValue('caller_id'));
incGr.setValue('short_description', current.short_description);
incGr.setValue('direction', 'Outbound');
incGr.insert();
action.openGlideRecord(incGr);
}
Vinod Kumar Kachineni
Community Rising Star 2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā12-24-2021 03:15 AM
This is working now.
Initially I was using the gsftsubmit to call UI action but was getting error in workspace while executing UI action
now I have Script to create Interaction in 'Script' field of UI action and script to open teams chat in Workspace Client script field , from where I am calling the UI action using g_from.submit();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā02-14-2024 07:39 AM
Just came across this and the solution had helped me, but i had to do a few tests to get it to work, which is basically as follows:
1 - Once your UI Action client side code execution is completed, it has to run the UI Action again. For that to happen you must add at the end of your client side function:
g_form.submit(actionName); // actionName = the value in the "Action name" field in the UI Action.
if (typeof window == 'undefined'){
runServerSide();
}
function runServerSide(){
// your code here...
}