Search code examples
javasalesforceapex

Extract Particular value from the result list and store them in another list


Hi I have a list type of List which is returned from the invocable action.

List<Invocable.Action.Result> results = action.invoke();

I am getting the data as below in the form of result.

(Result":[
   "action=Action":[
      "invocations=("{
         "QuestionDevName=testA",
         "ResponeValue=WBFH"
      }")",
      "invokeFromLightningComponent=false",
      "name=Tser",
      "namespace=null",
      "type=runDecisionMatrix"
   ],
   "errors=()",
   "invocationParameters=(already output)",
   "outputParameters="{
      IndividualScore=20.0
   },
   "success=true"
])

How to take out the IndividualScore and store in another list in below?

List<Integer> testInteger = new List<Integer>();

Trying below approach

testInteger = results.get(Result.outputParameters.IndividualScore);

Solution

  • https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Invocable_Action_Result.htm#apex_Invocable_Action_Result_getOutputParameters

    sounds like you need

    Object o = results[0].getOutputParameters().get('IndividualScore');

    and then Integer.valueOf(o) on this or something like that.