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 09:49 AM
Your best bet is to create a script include that handles the code. Then you can call it from both the UI Action and the Business Rule. If you need the script to be called from a client UI action, I recommend using AJAX. Your script include will look something like:
// this is called from the client
doSomethingAJAX : function() {
this.doSomething(this.getParameter('xxxx'), this.getParameter('yyyy');
}
// this is called from the BR
doSomething: function(param1, param2, ...) {
// have your code here that does the webservice/etc
}