can we call ui action from business rule?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 08:17 AM
can we call ui action from business rule?
can we call webservices from ui action?
i am calling this by making ui action list context menu
this code will work?
on click:showPopUp
function showPopUp(){
//var glideRecordToCheckIsMapped=new GlideRecord('u_mapping_spade_isell');
//glideRecordToCheckIsMapped.addQuery('u_is_mapped',false);
//glideRecordToCheckIsMapped.addOrCondition('u_is_rolledback','Yes');
//var encodedquery='u_is_mapped=false^u_is_rolledback=yesSTARTSWITH'+fake;
//glideRecordToCheckIsMapped.query();
alert('here row count is '+this.u_real_spade.getDisplayValue());
if(this.u_is_mapped.getDisplayValue()=='false' || this.u_is_rolledback.getDisplayValue()=='Yes'){
alert('The Rollback cannot be executed as the mapping operation has previously failed');
}else {
var rollbackSOAP = new sn_ws.SOAPMessageV2('Revert_copy', 'revertCopyFromRealToFake');
rollbackSOAP.setStringParameter('fakeSpadeOpportunityName', this.u_fake_spade.getDisplayValue());
rollbackSOAP.setStringParameter('realSpadeOpportunityName', this.u_real_spade.getDisplayValue());
rollbackSOAP.post();
var responseBody = rollbackSOAP.getResponse(5000);
gs.log("The response is " + responseBody, 'liyakhat');
if(responseBody.contains('Status : Success')){
try{
var revertWorkspaceCopyResponseXml = new XMLDocument(responseBody);
var copyFakeSpadeWorkspaceToRealReponse = copyWorkspaceResponseXml.getNodeText("//revertCopyFromRealToFakeReturn");
var faultCode = copyWorkspaceResponseXml.getNodeText("//faultcode");
var arrayOfRes = copyFakeSpadeWorkspaceToRealReponse.split(",");
var statusInfo=arrayOfRes[0];
var workspaceInfo=arrayOfRes[1];
var documentInfo=arrayOfRes[2];
var folderInfo=arrayOfRes[3];
var statusArray=statusInfo.split(":");
var status=statusArray[1];
var workspaceArray=workspaceInfo.split(":");
var noOfWorkspaceCopied=workspaceArray[1];
var documentArray=documentInfo.split(":");
var noOfDocumentsCopied=documentArray[1];
var folderArray=folderInfo.split(":");
var noOfFoldersCopied=folderArray[1];
this.u_is_rolledback='Yes';
this.u_rollback_status='OK';
this.update();
alert('rollback success');
/*
if(cel.contains('success')){
var ritmgr = new GlideRecord('sc_req_item');
ritmgr.addEncodedQuery(current.u_updated_ritms);
ritmgr.query();
while(ritmgr.next())
{
ritmgr.u_opportunity_code=current.u_fake_spade;
ritmgr.update();
}
}
else {
gr.u_is_rolledback='Yes';
gr.u_rollback_status='KO';
gr.update();
alert('rollback failure');
}
*/
}catch(err){
gs.log("Process response error "+responseBody,'YFD');
}
}else {
this.u_is_rolledback='Yes';
this.u_rollback_status='KO';
this.update();
alert('rollback failure'+responseBody);
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 08:39 AM
hi Kids,
1. It would not work, you cannot call UI action from Business Rule in your case, the UI Action, you have selected as Client (and you are calling a function onclick).
2. Calling a web service, the script is server side and you are trying invoke on client it would not work.
I would ask you to write a Before / After update business rule directly on table and you can display info message table if required. OR you want to make it Client specific, create a Script include and use a GlideAjax call to invoke web services.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 09:54 AM
explorenow Developer CommunityDiscuss shloke04 t_anurag
i am having list ui action button(rollback) when it is clicked it should display an alert when ismapped field is false in the table if it is true
it should call outbound message and take the success /failure value and display alert message on list view of the table.
how to achieve this functionality
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 09:44 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2017 12:52 AM
Hi kiddy ,
As damodarreddyp has already mentioned, you are not supposed to call UI action in the Business rule. To me, the best approach will be going with a Script include and call it inside the Server side code in your UI Action, as mentioned by akaupisch in his response.
Alternatively, I also can think about another solution. You can take some server side action (for example: update or insert) using the List Context menu. Now you can redefine your Business rule trigger condition accordingly as per your UI Action. Well, this is not a smart way after all, but there is a solution as this practically including Business rule and UI Action.
I hope this helps. Please mark correct/helpful based on impact