The CreatorCon Call for Content is officially open! Get started here.

UI Action not working on list view same one which is working on form

Ash41
Kilo Sage

Hello team, 

                 We have UI Action"Submit form" for on scoped app which is working fine on the form, but I want this to be work on list view, I have checked List choice. It is showing up there but not working.

Regards, 

Ash

1 ACCEPTED SOLUTION

Hi Nitin,

             I have got the resolution for my question, just unchecked the client on UI action and 2 lines code that resolved my issue. But thanks for the response I will have the above link handy for future reference which will work for global applications.

Regards, 

Ash

View solution in original post

6 REPLIES 6

Nitin Panchal
Tera Guru

Hi Ash, 

If its possible can you please share your UI action? 

Thanks

Sure, 

here is the screenshot

find_real_file.png

onClick()
{



if(g_form.getValue('status') == 'inital stage') {
var curNo = g_form.getValue('number');
var ga = new GlideAjax('check_dependent_exists');
ga.addParam('sysparm_name','DoesFEExist');
ga.addParam('sysparm_currentNo',curNo);
ga.getXML(FEParse);

function FEParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'Not Exist')
else if (answer == 'Exist')
gsftSubmit(null, g_form.getFormElement(), 'submitforms');
}
}
else if(g_form.getValue('status') == 'secont stage' && g_form.getValue('add_margin_fe') =='yes') {
var curNo = g_form.getValue('number');
var ga = new GlideAjax('check_dependent_exists');
ga.addParam('sysparm_name','DoesPOExist');
ga.addParam('sysparm_currentNo',curNo);
ga.getXML(FEParse);

function FEParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == 'Not Exist')
alert('Please select atlease one PO using the "Additional Margin PO Lists" section below');
else if (answer == 'Exist')
gsftSubmit(null, g_form.getFormElement(), 'submitforms');


}
}
else
gsftSubmit(null, g_form.getFormElement(), 'submitforms');
}

if (typeof window == 'undefined')
submitForm();

function submitForm() {
var wfRec = new GlideRecord('sysapproval_approver');
wfRec.addQuery('sysapproval',current.sys_id);
wfRec.addQuery('state','requested');
wfRec.query();
var wfRecStatus = wfRec.next();
if(current.status== "Intial stage" && !(wfRec.next())) {
current.tatus="secont stage";
current.update();

}
else {
var appRec = new GlideRecord('sysapproval_approver');
appRec.addQuery('sysapproval',current.sys_id);
appRec.addQuery('state','requested');
appRec.query();
while(appRec.next()) {
if(gs.hasRole("approval_admin") || (appRec.approver == gs.getUserID())) {
current.approval = 'approved';
current.update();
appRec.setValue('state','approved');
appRec.update();
break;
}
}
}
}

So I think g_form object will not work on list choice option of UI action. Because in List view user will select multiple record to perform the action, and in your UI action you are getting value from current form using g_form object. Check existing Delete UI action 

Ref:

https://community.servicenow.com/community?id=community_question&sys_id=98e203a1dbd8dbc01dcaf3231f96...

Ash41
Kilo Sage

Hi Nitin, 

              So, do I need create on more UI Action for submit form? in my case we are using existing UI on Form does this won't work?

Regards, 

Ash