Skip to main content
May 29, 2023
Question

a!writeToMultipleDataStoreEntities at interface for primary key

  • May 29, 2023
  • 4 replies
  • 0 views

Hi I have writeToMultipleDataStoreEntities in my interface, I wanted to retrieve only the primary key values when insert happen. 

onSuccess:a!save(local!emplEntity,fv!storedValues) 

    4 replies

    harshitb6843
    May 29, 2023

    I think it would be difficult as the key (idPk_int or id_int or idPK, etc.) of the entities will be different and hence you will have to include all of them so you do not miss out on any. What are you getting in 'local!emplEntity' after the smart services runs successfully? Can you attach a screenshot after expanding this variable? 

    May 29, 2023

    It should not be an issue if primary key names are same for all the entities. a!writeToMultipleDataStoreEntities() returns list of entityData type, so you can index or property the keys like you do with any dictionary or map.

    Here is a sample code: 

    a!save(
      local!primaryKeys,
      a!forEach(
        fv!storedValues,
        property(
          property(fv!item, "data", null),
          "idPk",
          null
        )
      )
    )

    stefanhelzle0001
    Brainy
    May 29, 2023

    The documentation explains how to extract data from the returned values.

    https://docs.appian.com/suite/help/23.2/Write_to_Multiple_Data_Store_Entities_Smart_Service.html#node-outputs

    May 29, 2023

    You are using writeToMultipleDataStoreEntities. so to get the value of the inserted/updated data, you have to use fv!storedValues[1] instead of fv!storedValues. [1] is the entity for which you want to get. it is counted as sequentially. For example: in writeToMultipleDataStoreEntities you update 3 tables and you want to get the data for 3rd table so for that use fv!storedValues[3]