Hi, i'm trying to execute 'apply' function to 'updatearray'

Hi, i'm trying to execute 'apply' function to 'updatearray' function, but it responds me with an error telling me that my input is not an array while my input is an 12 characters long array with all zero values e.g. {0,0,0,0,0,0,0,0,0,0,0,0}. Anything wrong with the things i have done?

A screenshot is attached for a clearer understanding.

OriginalPostID-174391

OriginalPostID-174391

  Discussion posts and replies are publicly visible

  • Hi Eric,
    Can you try with below snippet.
    So your code would be like this "apply(fn!updatearray(ri!array,_,_),{10},{1})".
    Thanks.
  • 0
    Certified Lead Developer
    Although the error message makes you think the issue is with apply() I think in your example the error is being propagated from updatearray(). Your example is syntactically wrong I'm afraid. The apply() function takes your 2nd parameter ri!array and passes each value, one iteration at a time, into fn!updatearray - this function expects an array as it's 1st parameter but apply() is only passing a single integer.
    What are you trying to achieve?
  • As tim mentioned, updatearray function itself iterates over an array so its input should be an array. In your expression as apply will execute this function for each value in your array, the input to the updatearray is value instead of array which is causing the issue.

    If you can specify what you want to achieve maybe we can suggest some approaches.
  • Hi,
    @ammireddys : Yes, your snippet work. Thanks
    @tim and ashish : Well, i'm trying to count the total document submitted per month base on the document submit date. So i'm thinking using the month() function to obtain the month of the submit date in integer and use the obtained integer as index for the ri!total, which is an array with length 12, and update the increment the related index array value by one. e.g. say the array of submit month is {Jan, Jan, March} so ri!total would be {2,0,1,0,0,0,0,0,0,0,0,0}