- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2019 06:37 AM
I have a record with a workflow with property condition "run the workflow always".
I have my atf steps to create and submit my form.
1) Should the workflow start? or do i have to start it within atf?
i have atf step after submit to query sysapproval_approver table.
i tried approving = record sysid (from submit step)
i tried approver = my approver sysid (i just hard coded)
my step fails, record cannot be found.
am i missing a step?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2019 10:04 AM
1) Should the workflow start? YES or do i have to start it within atf? NO
Most probably your script is running before the workflow completes the job.
Below is the example I can explain you with:
Lets say my Work flow, populates the location field for any sys_user record if its empty.
And My ATF script validates if any user record is created/modified, the location field is automatically populated as "11770 Bernardo Plaza Court, San Diego,CA"
Now, if you look at my ATF script below, if I implement it using step 1, 2 it would perhaps fail due to race condition. But it would work fine with steps 1,3 & 4.
Hope it helps!
-Manjul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2019 10:04 AM
1) Should the workflow start? YES or do i have to start it within atf? NO
Most probably your script is running before the workflow completes the job.
Below is the example I can explain you with:
Lets say my Work flow, populates the location field for any sys_user record if its empty.
And My ATF script validates if any user record is created/modified, the location field is automatically populated as "11770 Bernardo Plaza Court, San Diego,CA"
Now, if you look at my ATF script below, if I implement it using step 1, 2 it would perhaps fail due to race condition. But it would work fine with steps 1,3 & 4.
Hope it helps!
-Manjul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2019 03:53 AM
my workflow does run.
my workflow has an if condition based upon a field value.
in my atf i set the field value, step passes.
I have found that the workflow runs correctly when i manually create and submit the form through the platform,
but
when i use ATF, the value in my if condition is not set - I set it to 'yes'
but the workflow takes the opposite path (does not recognize value of yes)
I put in scripts to gs.info the value but i found that these statements are not printed to the log.
to see my field values i had to put in a notification with field values in the body: ${field name}
when run manually my field value of yes is perfect so workflow takes the correct path.
when run through atf field value is NOT yes so workflow takes the opposite path.
now, i realize that i can change my logic to if field_value is not yes
but i do not understand why a workflow, when run in atf, is not recognizing my values.
has no one come across this problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2019 04:23 AM
i just found the Log Message activity and the workflow object for writing messages.
how do i print the value of a field on my form?
current.my_field_name does not seem to work
${field_name} does not work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-14-2019 10:48 AM
HI,
We use below script to approve the record.
(function(outputs, steps, stepResult, assertEqual) {
var grApprov = new GlideRecord('sysapproval_approver');
//grApprov.addEncodedQuery('sysapproval.ref_sc_req_item.cat_item=741905dedb94e3408812644a4b9619e1^state=requested');
var a = steps('31d4b568dbe4ab408812644a4b961922').record_id;//Step in which record is checked if it exist or not.
// Sys Id of the Requested item
grApprov.addQuery('document_id', a);
grApprov.addEncodedQuery('state=requested^approver=97f6e537db2593402a6f16f35b961993');
grApprov.orderBy('sys_created_on');
grApprov.query();
//Check if the approver and approval type are as expected
if (grApprov.next()){
if(grApprov.approver=='97f6e537db2593402a6f16f35b961993'){
stepResult.setOutputMessage("abc" + 'Correct approver and approval type');
}
grApprov.state = 'approved';
grApprov.update();
}
})(outputs, steps, stepResult, assertEqual);
No need to start workflow explicitly it will be automatically triggered once record is submitted.
Thanks,
Ashutosh