Inbound Email Actions multiple update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2016 12:34 AM
Hi Experts
I have a really complicated issue.
I have created an inbound Email Action for a Time Card Approval Process.
this inbound Action is triggered when an approve email comes from a manager with Subject == approve.
The Target Table is Sys_User as my Notification Template must be on the Sys_user Table but the information that needs to be updated and approve is on the Time Card Table.
Now In my Inbound Action as I said Target is Sys_user and then in the script I GlideRecord Time card table with the fitler of the user that is requesting this approval.
The GlideRecord is working and giving me the correct data.
Now I just need to approve each record (changing state from Submitted to Approved) in the Time card table.
e.g. User A have 3 Time Records submitted, the manager gets an email with all 3 records and he approves via email. the Inbound action started and gliderecord filtering the user and in the while statement I can log all 3 data and see them but when I say gr.update(); to update my state, it only update one record. even it is running threw all 3.
Does anyone have an idea what is running wrong?
if (email.subject.indexOf("approve") >= 0) {
var gr = new GlideRecord('time_card');
gr.addQuery('user', current.sys_id);
gr.addQuery('state', 'Submitted');
gr.query();
while(gr.next()) {
gs.log('TIME INBOUND APPROVED for CURRENT USER: ' + current.name);
gr.state = "Approved";
gr.update();
}
}
thanks
Elias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2016 01:06 AM
It has something to do with my BR as when I run it I got this log: so it is only updating one record PRJ0010101 with sysid: 67c8698a0fad6240212ac4dce1050e38.
USINESS RULE - About to execute business rule 'user query' on sys_user:
BUSINESS RULE - Skipping execution of user query on sys_user:; condition not satisfied: Condition: gs.getSession().isInteractive() && !gs.hasRole("admin")
*** Script: TIME INBOUND APPROVED for CURRENT USER: Lauren Andersen TOTAL 13 SYSID = fff9a27f0fe78600f6fefe5ce1050e10
BUSINESS RULE - About to execute business rule 'IfTaskNameChanges' on time_card:PRJ0010101
BUSINESS RULE - Skipping execution of IfTaskNameChanges on time_card:PRJ0010101; condition not satisfied: Condition: current.u_task_description.changes(); Filter Condition: u_task_descriptionVALCHANGES^EQ
BUSINESS RULE - About to execute business rule 'WeekStartdateValidation' on time_card:PRJ0010101
BUSINESS RULE - Skipping execution of WeekStartdateValidation on time_card:PRJ0010101; condition not satisfied: Filter Condition: week_starts_onVALCHANGES^EQ
BUSINESS RULE - About to execute business rule 'Calculate AllowedTotal' on time_card:PRJ0010101
BUSINESS RULE - Finished executing business rule 'Calculate AllowedTotal' on time_card:PRJ0010101
BUSINESS RULE - About to execute business rule 'Calculate total' on time_card:PRJ0010101
BUSINESS RULE - Finished executing business rule 'Calculate total' on time_card:PRJ0010101
completed (67c8698a0fad6240212ac4dce1050e38): event=update
......
.....
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2016 01:20 AM
Elias,
Make sure that you don't have 'setWorkflows(false) in one of your business rules that is being triggered while updating the records
This method deactivate all the BR that are supposed to operate.
I also advice you to delete your URL cache and give a try again.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2016 01:22 AM
Yeah thanks for your advise,
I think I have found the wrongdoer! it is definitely a BR. I have deactivate all BR from the TIMECARd and my update is working,
now I am checking where I did added this 'setWorkflows(false) and also I activate step by step my BR
Thanks
Elias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2016 01:50 AM
I dont have any setWorkflows(false) on my BR but I have a lot of updating records on timecard. does this not allowing me 2 scripts updating the same record?
Elias
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2016 01:56 AM
and have you got a current.setAbortAction(true) ?
maybe there is a conflict within these 2 scripts.... if the scripts don't update the same field, try again by giving them two different orders... So they can be fully executed one by one.