Workflow script calculation depending on selected lookup value


I’m trying to build a form, that will calculate a score depending on which attributes are selected.

I’ve started off trying to test, I could return a value, if the variable matched.
I have a variable called Gradient which should return the value of a lookup attribute.
And a parameter with a script to add 20 if the “Gradient” variable matches an AlloyId

But the script doesn’t get True condition when tested. The output is 0 instead of 20.

  "ancestorId": "",
  "signature": "",
  "description": "Test conditional logic",
  "parameters": [
      "discriminator": "WorkflowComputedItemAttributeWebModel",
      "attributeCode": "attributes_gritBinCriteriaFormScore_654b90e5be0fff779ced3447",
      "value": {
        "discriminator": "WorkflowSyntaxNodeScriptWebModel",
        "script": "var myNum = 0; if (Gradient[0] == AlloyId(\"654b85cd2b32a3b7d64911fe\")) {myNum+=20;} return myNum;",
        "returnOptions": null
  "variables": [
      "name": "Gradient",
      "value": {
        "discriminator": "WorkflowSyntaxNodeInputWebModel",
        "inputParent": 0,
        "itemValue": {
          "discriminator": "WorkflowSyntaxArgumentItemValueAttributeWebModel",
          "attributeCode": "attributes_gritBinCriteriaFormSeverityOfGradient_654b892cd420bc4aab4d65e0"
  "actionDesignCode": "designs_workflowEditItemAction"

Update: Instead of doing the calculation for each attribute choice within a c# script, I’ve instead made a normal workflow to update a Value Attribute for each choice.
Then created a much simpler workflow to add up all those results.

It still would be interesting to know if what I was attempting is possible.

Hi Howard,

You will need to use Equals(Gradient[0], AlloyId("654b85cd2b32a3b7d64911fe")) there. Or alternatively something like $"{Gradient[0]}" == "654b85cd2b32a3b7d64911fe".

Apologies I wrote this back in November but never clicked the reply button!

1 Like