Forum Discussion
Jamesvan_der_Wa
Qrew Trainee
Thanks for the quick reply Dwight,
Sadly the solution didn't work.
First, I see you put quotations around all the variables. If I do that then all of these are just strings in the final output.
Second, If I remove the quotation then the body section of the "Make Request" doesn't validate.
------------------------------
James van der Walt
------------------------------
DwightMunson1
2 years agoQrew Assistant Captain
Maybe it has to do with the white space around the jinja expressions? I should have taken that out.
This is what I do with mine, in which I query records in a work request table to find work to charge project management time to. That data is the b.json.data. Then I use this step to loop through the data and create time cards up to the time in a.hours.
Make a request step:
Method: POST
Content Type: Application/json
Body:
{
{% set myDataSet = "myDBID" %}
{% set myTimeStop = namespace(val=a.hours) %}
{% set runningTotal = namespace(val=0.0) %}
{% set relatedTimeSheet = namespace(val=a.related_time_sheet) %}
{% set relatedWorkCode = namespace(val=a.related_work_code) %}
{% set relatedClass = namespace(val=a.related_class) %}
"to": "{{myDataSet}}",
"data":[
{% for row in (b.json.data) if runningTotal.val < myTimeStop.val %}
{% set remainingTime = myTimeStop.val - runningTotal.val %}
{% set currentValue = row['33'].value if row['33'].value <= remainingTime else remainingTime %}
{% set runningTotal.val = runningTotal.val + currentValue %}
{
"37":{
"value": "{{row['36'].value | int}}"
},
"39":{
"value": "{{row['8'].value | int}}"
},
"28":{
"value": "{{relatedWorkCode.val | int}}"
},
"42":{
"value": "{{relatedClass.val | int}}"
},
"655":{
"value": "{{row['13'].value | int}}"
},
"227":{
"value": "{{currentValue}}"
},
"34":{
"value": "{{relatedTimeSheet.val | int}}"
}
}
{% if loop.last == false and runningTotal.val <= myTimeStop.val %},{% endif %}
{% endfor %}
]
}
------------------------------
Dwight Munson
------------------------------