Custom outputs aren't being stored to process variable

I am having trouble with values saving to every custom output object. My write to data store activity inserts multiple rows. I am trying to use the saved entities id and a manual value to then write to a process variable.

Example:

These would be my activity's custom outputs saved into the process variable:
1. ac!StoredValues.id
2. today()

However, the output would look like:

{"john", "2020-06-11},  {"amy", null},  {"steve", null}  -- today() is only saved for the 1st object.

I tried wrapping today() function in a repeat, but it still gave the same outputs

1. ac!StoredValues.id
2. repeat(length(ac!StoredValues), today())

  Discussion posts and replies are publicly visible

Parents Reply Children
  • I just tried all three of your suggested methods and unfortunately non of them resolved the issue

  • 0
    Appian Employee
    in reply to seze

    Are you saving both of those outputs into the same process variable? And are you also saving into that same variable elsewhere in the write to data store activity? If yes to either of those, I'd suggest trying to reconfigure this to only save the output of a single expression into that variable. That's why I suggested doing this in the next script task because then you should ensure that all the information is saved in one step.

    I must confess, I'm also a bit confused why you are saving today() into a varaible after inserting data into the database - wouldn't you want to save the date to the database too? If yes, then I'd suggest saving today() into the variable prior to performing the write to data store (perhaps on the form).

    If none of these work, can you provide a bit more information about how you set this up? What variables do you have, what are you writing to the database, and what is the full list of your outputs, etc.

  • Yes both are being saved to the same process model.

    No, the input is a different process variable.

    The example was for simplicity sake. We have a process that runs nightly and generates a task for user input. The data from this form populates table A in our process model. Within the process model there are other activities that reference what was just entered into table A, hence our need for the IDs from StoreValues. The output process variable has today() to track this part of the process ran and store into table B with a key reference to Table A.

    Are you saying to have the stored value in it's entirety saved as a process variable and then a script task to write to the needed process variable?

  • 0
    Appian Employee
    in reply to seze

    Ah okay that makes sense - thanks for the clarification! In that case, can you create a single output using a!forEach() that creates a list of lists? For example, try this:

    a!forEach(
      items: ac!StoredValues,
      expression: {
        id: fv!item.id,
        date: today()
      }
    )

    Then, you can save this entire result into your process variable for table B. This should generate the correct number of items and ensure that all the data is defined in a single save.

  • So I took the approach of creating a list of just the ID's after writing to table A instead of creating the object process variables. Its followed by a script that loops through the list to create the process variable objects. Its an extra step, but its working.