none
How to get a substring in a Workflow Activity? RRS feed

  • Question

  • I'm concatenating some values into a Summary field in a workflow activity as follows:

    IIF(Eq([//Target/Code1],True),"1,","")+IIF(Eq([//Target/Code2],True),"2,","")+IIF(Eq([//Target/Code3],True),"3,","")

    So if Code1 and Code2 are true I get a Summary Value of 1,2,

    Now I want to trim the trailing comma.

    So I did this

    Left([//Target/Summary],Add(Length([//Target/Summary]),-1))

    This part doesn't work.  It says Left is improperly formatted or missing a parameter.

    If I put a numeric value like 1 or 2 as the second value it works.

     Any suggestions on how to get trim a character off the end of a string in a FIM Workflow activity?

    Thursday, April 30, 2015 8:20 PM

Answers

  • Length isn't a function supported by the FIM Function evaluator Workflow activity. (Which is frustrating).

    Here is my sloppy approach using the built-in tool (lots of nesting so if you need to do this for more than 3 conditions this grows out of control):

    IIF(Eq([//Target/Code1],True),IIF(Eq([//Target/Code2],True),IIF(Eq([//Target/Code3],True),"1,2,3","1,2") ,IIF(Eq([//Target/Code3],True),"1,3","1") ) ,IIF(Eq([//Target/Code2],True),IIF(Eq([//Target/Code3],True),"2,3","2") ,IIF(Eq([//Target/Code3],True),"3","") ))

    OR you can use one of these custom workflows that allows you to run your own code:

    http://fimwf.codeplex.com/

    or

    https://fimactivitylibrary.codeplex.com/wikipage?title=Code%20Run%20samples&referringTitle=Documentation


    David Lundell, Get your copy of FIM Best Practices Volume 1 http://blog.ilmbestpractices.com/2010/08/book-is-here-fim-best-practices-volume.html

    • Marked as answer by j.greene Thursday, May 7, 2015 3:15 PM
    Friday, May 1, 2015 4:20 AM

All replies

  • Length isn't a function supported by the FIM Function evaluator Workflow activity. (Which is frustrating).

    Here is my sloppy approach using the built-in tool (lots of nesting so if you need to do this for more than 3 conditions this grows out of control):

    IIF(Eq([//Target/Code1],True),IIF(Eq([//Target/Code2],True),IIF(Eq([//Target/Code3],True),"1,2,3","1,2") ,IIF(Eq([//Target/Code3],True),"1,3","1") ) ,IIF(Eq([//Target/Code2],True),IIF(Eq([//Target/Code3],True),"2,3","2") ,IIF(Eq([//Target/Code3],True),"3","") ))

    OR you can use one of these custom workflows that allows you to run your own code:

    http://fimwf.codeplex.com/

    or

    https://fimactivitylibrary.codeplex.com/wikipage?title=Code%20Run%20samples&referringTitle=Documentation


    David Lundell, Get your copy of FIM Best Practices Volume 1 http://blog.ilmbestpractices.com/2010/08/book-is-here-fim-best-practices-volume.html

    • Marked as answer by j.greene Thursday, May 7, 2015 3:15 PM
    Friday, May 1, 2015 4:20 AM
  • Thanks for the response and the suggestion.

    I actually have 5 codes so I took your suggestion and added some steps to my workflow like this:

    This is most of it.  The problem I have is that the values that should be going into the WorkflowData targets don't seem to be populated when I try to use them in step 3.  Am I missing something basic?

    Value Expression Target
    1 IIF(Eq([//Target/Code1],True),IIF(Eq([//Target/Code2],True),"1,2","1"),IIF(Eq([//Target/FERC2],True),"2",".")) [//WorkflowData/Summ12]
    2 IIF(Eq([//Target/Code3],True),IIF(Eq([//Target/Code4],True),"3,4","3"),IIF(Eq([//Target/Code4],True),"4",".")) [//WorkflowData/Summ34]
    3 IIF(Eq([//WorkflowData/Summ12],"."),IIF(Eq([//WorkflowData/Summ34],"."),".",[//WorkflowData/Summ34]),IIF(Eq([//WorkflowData/Summ34],"."),[//WorkflowData/Summ12],[//WorkflowData/Summ12]+","+[//WorkflowData/Summ34])) [//WorkflowData/Summary]




    • Edited by j.greene Tuesday, May 5, 2015 2:52 PM
    Tuesday, May 5, 2015 2:49 PM
  • I suggest creating a logging activity and putting it in place in between each step to ensure that they are really populating. That or switch to the C# workflow activity and then you can just do it in much simpler code

    David Lundell, Get your copy of FIM Best Practices Volume 1 http://blog.ilmbestpractices.com/2010/08/book-is-here-fim-best-practices-volume.html

    • Marked as answer by j.greene Thursday, May 7, 2015 3:15 PM
    • Unmarked as answer by j.greene Thursday, May 7, 2015 3:15 PM
    Wednesday, May 6, 2015 12:47 AM