- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2017 09:42 AM
I have extended both the request and the requested item tables to create two new tables: position and required item, respectively. This is to allow people to define what catalog items are required for new hires so we can automatically script creation of the requested items upon submission of the onboarding form. In the process, I have approvals on both the position and the required item and we need to allow "rework" of the information if rejected. This is functioning without any issues on the position, but failing on my required items and I cannot figure out why. I'll try to provide as much info as possible:
On the approval table, I added a field u_approval_type that captures if the rejection is complete or they just want the information updated.
If the approver decides the required item needs update, the required item loops back to "draft" state and becomes editable.
Once ready for approval again, the user clicks a UI Action called "Request approval" that runs this script:
action.setRedirectURL(current);
current.state=9;
current.update();
gs.include('ActionUtils');
var au = new ActionUtils();
au.postInsert(current);
This is appropriately setting the state back to Required item review (or Position review on the position):
but you can see that the Approval is not going back to "requested" as it should on required item. This is what the running workflow looks like:
And this is what the wait condition is running:
answer = ifScript();
function ifScript(){
if(current.state == 9){
return true;
}
else{
return false;
}
}
It was originally not using a function, but that also didn't work. (It was just the if/else with "answer = true;" or "answer = false;"). I added logging at one point and I get logs when the required item doesn't meet the condition, but upon clicking the UI action and the update of the record to "Required item review", the condition never triggers again. I'm baffled as to why.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2017 01:58 PM
I finally was able to get it to move forward. I made an adjustment to the script you suggested so that it matched the "nudge" ui action on workflow context:
(function executeRule(current, previous /*null when async*/) {
resumeWorkflow();
function resumeWorkflow() {
gs.info('resumeWorkflow called on required item');
var wf = new Workflow().getRunningFlows(current);
while(wf.next()) {
gs.info('resumeWorkflow found the workflow');
new Workflow().broadcastEvent(wf.sys_id, 'update');
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2017 12:46 PM
Hi Kristen,
You are right if the workflow is for the same table then you dont need the resume workflow business rule and you can skip it. So I am going to try one more thing here. So say we go back to where you had initially questioned and revert your code to original code. Then add a say 5 second workflow activity timer to check the waitForCondition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2017 01:58 PM
I finally was able to get it to move forward. I made an adjustment to the script you suggested so that it matched the "nudge" ui action on workflow context:
(function executeRule(current, previous /*null when async*/) {
resumeWorkflow();
function resumeWorkflow() {
gs.info('resumeWorkflow called on required item');
var wf = new Workflow().getRunningFlows(current);
while(wf.next()) {
gs.info('resumeWorkflow found the workflow');
new Workflow().broadcastEvent(wf.sys_id, 'update');
}
}
})(current, previous);