Preferred 9.x replacement to pass array of strings

When I created a function in 7.6 I needed to add the ework object and args string array as the parameters.

 

public static function retSomething (ework: SyncProcessData, args: Object[]) : String

 

In 9.x and converting to C# I replace ework with ProcessContext, add a process object variable and add the args...

 

public static string retSomething(prcData p, string args[])

 

But I'm having trouble passing data into the "args[]" array...  I can't pass something like new string[] {"Hello","World"} as the value for the parameter - I get a weak error that says I'm missing an assembly.

 

There must be a way to pass in an array of strings...

 

 

Tagged:

Comments

  • I think your function signature might not be declared correctly. Note the way I'm declaring the string array.

     

    public static string GetString0WithUserName(ProcessContext pc, string[] inputStrings)
        {
            return inputStrings[0] + pc.UserName;
        }   
    
        public static void LogTheString()
        {
            ProcessContext pc = new ProcessContext();
            string x = GetString0WithUserName(pc, new string[]{"0","1","2"});
            Mstm.WriteToLog("test",x,Severity.Information);
        }
    

     

  • Oops the string[] args was a typo...

    Looking at your solution my problem would be promoting "GetStringWithUserName" to the Expression Builder.

    How do you pass new string[]{"0","1","2"} in the expression builder?

  • It should be the same... Assuming you've decorated the function to promote it, it should show up in the expression builder. This is what I put into the expression builder and it works without issue.

     

    ServerScript1.GetString0WithUserName(new ProcessContext(), new string[]{"0","1","2"})
    

     

     

  • Thanks! I had a bug in the function itself. But, on a side note - I'm calling this function from a roles expression and need to get to process variables, but I can't pass Current.
    Would you recommend declaring process.Declarations.processData1 as a function parameter?

  • There's multiple ways to define a dynamic role as long as the formula returns a Metastorm.Runtime.Types.List of valid eUserNames. You should probably use a SelectSql().List to query the process table by ProcessContext.FolderId or... yes, you can instantiate the process and inspect the process's "ProcData" to get to the process variable. My feeling is that this would be more expensive than a SelectSql().List, especially if you have a lot of variables, but it is still valid.

     

    ListItems(new ProcRoleProcData().ProcRoleProcDataData.txtApprover)
    

     The name of the process is "ProcRoleProcData", so the strongly typed "ProcData" object would be off of it  would be "ProcRoleProcDataData", and below that would be your process variables, in this case a variable called "txtApprover".


  • Mike T wrote:
    Thanks! I had a bug in the function itself. But, on a side note - I'm calling this function from a roles expression and need to get to process variables, but I can't pass Current.
    Would you recommend declaring process.Declarations.processData1 as a function parameter?


    Yes, that is the best way to do this. The object is "Process1.Declarations.Process1Data" in a default new solution. To pass it into the function just type "Process1Data" (no quotes in any of this) or its equivilent. I often select a variable from the BO menu in the Expression Builder and delete the variable.