Untitled
unknown
json
2 years ago
9.5 kB
5
Indexable
{ "acceptPrps": { "requiredAttr": "array", "optionalAttr": "array", "actionsOnSuccess": "array", "saveButtonId": "string", "isAddNew": "boolean", "saveAction": "string", "dtaObj": "string", "isNotUpdated": { "type": "boolean", "dft": true }, "statusId": { "type": "string", "dft": "1" } }, "prps": { "fireScript": { "id": "saveScript", "actions": [ { "type": "setState", "target": "%saveButtonId%", "key": "enabled", "value": false }, { "comment": "create a new array", "scope": "saveScript", "type": "setVariable", "name": "allAttr", "value": [] }, { "type": "applyComparison", "operator": "isTruthy", "value": "$isNotUpdated$", "branch": { "true": [ { "scope": "saveScript", "type": "pushVariable", "name": "allAttr", "value": { "atr": "CreatedBy", "val": "((saveScript.state.app.userCode))" } } ] } }, { "type": "applyComparison", "operator": "isTruthy", "value": "$isAddNew$", "branch": { "true": [ { "scope": "saveScript", "type": "pushVariable", "name": "allAttr", "value": { "atr": "StatusId", "val": "%statusId%" } } ] } }, { "type": "applyComparison", "operator": "isEqual", "compareValue": "null", "value": "((saveScript.state.addDebtors.debtorsCi))", "branch": { "true": [ { "scope": "saveScript", "type": "pushVariable", "name": "allAttr", "value": { "atr": "CustomerInstructionId", "val": null } } ], "false": [ { "scope": "saveScript", "type": "pushVariable", "name": "allAttr", "value": { "atr": "CustomerInstructionId", "val": "((saveScript.state.addDebtors.debtorsCi))" } } ] } }, { "type": "applyComparison", "operator": "isEqual", "compareValue": "null", "value": "((saveScript.state.addDebtors.debtorsSi))", "branch": { "true": [ { "scope": "saveScript", "type": "pushVariable", "name": "allAttr", "value": { "atr": "ShippingInstructionId", "val": null } } ], "false": [ { "scope": "saveScript", "type": "pushVariable", "name": "allAttr", "value": { "atr": "ShippingInstructionId", "val": "((saveScript.state.addDebtors.debtorsSi))" } } ] } }, { "comment": "add each object in the required attr to the array", "id": "saveScript-mia", "type": "morphIterateArray", "recordVarName": "record", "value": "$requiredAttr$", "chain": [ { "scope": "saveScript", "type": "pushVariable", "name": "allAttr", "value": { "atr": "((saveScript-mia.variable.record.key))", "val": "((saveScript-mia.state.((saveScript-mia.variable.record.valueId)).((saveScript-mia.variable.record.valueType))))" } } ] }, { "comment": "add each object in the optional attr to the array if it has a value", "id": "saveScript-mia2", "type": "morphIterateArray", "recordVarName": "record", "value": "$optionalAttr$", "chain": [ { "type": "applyComparison", "operator": "isNotFalsy", "value": "{{saveScript-mia2.state.((saveScript-mia2.variable.record.valueId)).((saveScript-mia2.variable.record.valueType))}}", "branch": { "true": [ { "scope": "saveScript", "type": "pushVariable", "name": "allAttr", "value": { "atr": "((saveScript-mia2.variable.record.key))", "val": "((saveScript-mia2.state.((saveScript-mia2.variable.record.valueId)).((saveScript-mia2.variable.record.valueType))))" } } ] } } ] }, { "type": "queryGateway", "serializeAttrs": true, "defaultEmptyStrings": null, "queryData": { "action": "vld_exec_nom", "token": "((saveScript.state.app.token))", "parameters": { "attrs": "{{saveScript.variable.allAttr}}", "save_action": "%saveAction%", "dtaObj": "%dtaObj%" } }, "extractResults": [ { "path": "response.success", "variable": "success" }, { "path": "response.result.1.serviceresult.response.fields.Id", "variable": "id" } ] }, { "type": "setState", "target": "appDashboard", "key": "idForLineItemFilter", "value": "{{saveScript.variable.id}}" }, { "type": "applyComparison", "operator": "isEqual", "value": "{{saveScript.variable.success}}", "compareValue": true, "branch": { "true": "$actionsOnSuccess$", "false": [ { "type": "showNotification", "msgType": "warning", "msg": "Record failed to add" }, { "type": "setState", "target": "%saveButtonId%", "key": "enabled", "value": true } ] } } ] } } }
Editor is loading...