Issue with query in portal widget

Admin7267
Kilo Sage

Hello,

 

I have created an widget on RITM page to trigger an reminder email but I'm unable add query for current RITM that is displayed.

If I removed gr.addQuery('document_id', data.sys_id);  then it's triggering approvals for all my requests.

data.sys_id = input.sys_id || $sp.getParameter("sys_id");

var gr = new GlideRecord('sysapproval_approver');
gr.initialize();
gr.addQuery('state', 'requested');  
gr.addEncodedQuery("sysapproval.u_requested_for=javascript: gs.getUserID();");
gr.addQuery('document_id', data.sys_id);  //  Not Working
gr.addQuery('source_table','sc_req_item');
gr.query();  
while (gr.next()) {  
gs.eventQueue("approval.reminded",gr, gs.getUserID(), gs.userName()); 
gs.log("Email triggered for = "+data.sys_id);
}

 

Can you please correct me where I did wrong, notification should sent to current RITM only ?

 

Thanks,

Tarun

 

1 ACCEPTED SOLUTION

Hey ,

then i think the problem is with document id field , its always a mess with this type of field .Instead of Document ID field which is "Approving" of approver form there is one more field which stores the approval record sys_id which is "Approval For"

can you please try replacing the addQuery like below

gr.addQuery('sysapproval', data.sys_id); // query with Approval for instead of document_id

I tried to query with Approving for field and it worked for me 

can you please try this ?

Please accept the solution if it helps you

 

 

View solution in original post

4 REPLIES 4

Mohith Devatte
Tera Sage
Tera Sage

Hello,

Did you try to check the log what is coming in data.sys_id variable ?

and can you tell me if in the URL of the RITM page do we have &sys_id = "12345" something like this?

Thank you @Mohith Devatte for responding to my question. Yes, I checked and data.sys_id is having the sys_id of RITM which is 97928746878c111009fbb91acebb350b 

.com/sp?id=ticket&table=sc_req_item&sys_id=97928746878c111009fbb91acebb350b&view=sp

Hey ,

then i think the problem is with document id field , its always a mess with this type of field .Instead of Document ID field which is "Approving" of approver form there is one more field which stores the approval record sys_id which is "Approval For"

can you please try replacing the addQuery like below

gr.addQuery('sysapproval', data.sys_id); // query with Approval for instead of document_id

I tried to query with Approving for field and it worked for me 

can you please try this ?

Please accept the solution if it helps you

 

 

Thank you @Mohith Devatte, now it's working as expected.