UI Action doesn't perform OnClick and Server side function
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2017 04:55 AM
Hi Team,
I am trying to create a UI Action in which I want user to type in a text (On click) of that action and once they type in the text in the box then the server side function should execute.
Below is my script which is not working presently and I am not sure what I have missed out here.
function clientCode() {
var tableName = g_form.getElement("name").value;
var tableLabel = g_form.getElement("label").value || tableName;
var keyword = new GwtMessage().getMessage("cancel").toLowerCase();
var msg = new GwtMessage().format("Type the word \"{0}\" here", keyword);
var name = prompt(new GwtMessage().format("To cancel the action {0}", tableLabel), msg);
if (name || name.toLowerCase() == keyword) {
{
var fields = g_form.getEditableFields();
for(var x=0; x<fields.length; x++){
if (fields[x]!='sys_created_on' && fields[x] != 'sys_created_by' && fields[x]!= 'sys_updated_on' && fields[x] != 'sys_updated_by')
g_form.setMandatory(fields[x],false);
}
return;
}
gsftSubmit(null, g_form.getFormElement(), 'cancel_now');
}
}
if(typeof window == 'undefined')
runSumrule();
function runSumrule(){
current.deleteRecord();
var gr3 = new GlideRecord('x_governa_pm_sl_s');
gr3.addQuery('sys_id',current.getValue('sum_id'));
gr3.query();
if(gr3.next()){
gs.addInfoMessage('Clarification Request has been Cancelled');
action.setRedirectURL(gr3);
//current.deleteRecord();
}
}
Appreciate your quick response.
Regards,
Narmi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2017 05:15 AM
Hi Narmi,
Can you please try with returning false from the client side instead of just "return"
return false;
Also, I hope you can the action name populated on the UI action.
At last, you can check the logs and add some loggers for inside information.
Thanks
Gaurav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2017 05:17 AM
Hi Narmi,
Is the action name "cancel_now"? Also, Do you have any other UI action with the OnClick named "runSumrule"?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2017 06:36 AM
Hi Rafeal,
I made the changes to the function name and the action name is 'cancel_now' still it doesn't work.
function clientCode() {
var tableName = g_form.getElement("name").value;
var tableLabel = g_form.getElement("label").value || tableName;
var keyword = new GwtMessage().getMessage("cancel").toLowerCase();
var msg = new GwtMessage().format("Type the word \"{0}\" here", keyword);
var name = prompt(new GwtMessage().format("To cancel the action {0}", tableLabel), msg);
if (name || name.toLowerCase() == keyword) {
{
var fields = g_form.getEditableFields();
for(var x=0; x<fields.length; x++){
if (fields[x]!='sys_created_on' && fields[x] != 'sys_created_by' && fields[x]!= 'sys_updated_on' && fields[x] != 'sys_updated_by')
g_form.setMandatory(fields[x],false);
}
return false;
}
gsftSubmit(null, g_form.getFormElement(), 'cancel_now');
}
}
if(typeof window == 'undefined')
runSumrule();
function runfaste(){
current.deleteRecord();
var gr3 = new GlideRecord('x_governa_pm_sl_s');
gr3.addQuery('sys_id',current.getValue('sum_id'));
gr3.query();
if(gr3.next()){
gs.addInfoMessage('Clarification Request has been Cancelled');
action.setRedirectURL(gr3);
//current.deleteRecord();
}
}
Regards,
Narmi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2017 06:46 AM
Can you please check the logs on console for any errors?
Also, place some logs in server-side script and see that they are running through it or not?
You can also use script debugger for it.
PS: I hope you are clicking again on the UI action button once the client side script is satisfied.
I am trying to create a UI Action in which I want user to type in a text (On click) of that action and once they type in the text in the box then the server side function should execute.