Skip to main content
March 9, 2024
Question

How to configure an array that is autopopulated by another array field to be saved in the database.

  • March 9, 2024
  • 9 replies
  • 0 views

Hello,

"Can you please help me? My array field, which is auto populated from another array field, takes the information but does not save it in the database. How can I adjust it to save?"

I intend to get "Codigo Finca" auto populate from a "Finca" field array list.

my interface code:

My expression rule:

property(a!queryEntity(
  entity:cons!SCP_FINCA_DSE,
  query: a!query(
    selection: a!querySelection(
      columns: {
        a!queryColumn(field: "codigoFinca"),
        a!queryColumn(field: "id"),
        a!queryColumn(field:"value")
      }
    ),
    pagingInfo: a!pagingInfo(1,-1)
  )
 ),"data",null)

Appreciate your help.

Regards,

    9 replies

    karumurua531442
    March 10, 2024

    Hi [mention:905cb236a77a414caf2214c2a361d317:e9ed411860ed4f2ba0265705b8793d05]  I did not get your question, could you give more context on this please

    dhananjayk3480
    March 10, 2024

    Please elaborate your ask

    stefanhelzle0001
    Brainy
    March 10, 2024

    The code you shared does not include anything that would save data to the database.

    davidj137213
    Brainy
    March 10, 2024

    I assume that you are trying to update the record in the database, using the saveInto parameter in the dropdown.

    This will only update the record locally, but will not save it to the database. If you want to update the record in the database, you will have to use either the smart service Writerecords in a PMO or the a!writeRecords function in your interface

    prakhars0731
    March 11, 2024

    Not sure but I think you want write a record using a array.

    tejak2639
    March 11, 2024

    Hi,
    Did got the question. 
    From my assumption,
    You are trying to perform cascading dropdown like from first drop down based on selected value you want to get the choice values in the second drop down
    If that is the case then use wherecontains in choice values and choicelables to get the value.
    Or
    If you are trying to write into database provide writerecord in submit button or use process model for writing the data to database.
    Provide detailed view if these are not the cases.

    March 11, 2024

    hello, thank to all for the replies.

    Tejakunchala, you are correct,  I´m trying to perform cascading dropdown like from first drop down based on selected value, I want to get the choice values in the second drop down ( autopopulate in the second dropdown).

    This is a start form, so it´s is writng to a record on the PM.

    can you pls guide me on the code you are suggesting me.

    thanks a lot.

    tejak2639
    March 12, 2024

    Hi,

    a!dropdownField(
    placeholder: "Select-Country",
    choiceLabels: index(local!Countries,"country",null()),
    choiceValues: index(local!Countries,"countryId",null()),
    value: fv!item.country,
    saveInto: {fv!item.country,a!save(fv!item.state,null())}
    ),
    a!dropdownField(
    placeholder: "Select-state",
    choiceLabels: if(a!isNullOrEmpty(fv!item.country),local!states.state,index(local!states[wherecontains(tointeger(fv!item.country),local!states.countryId)],"state",null())),
    choiceValues: if(a!isNullOrEmpty(fv!item.country),local!states.stateId,index(local!states[wherecontains(tointeger(fv!item.country),local!states.countryId)],"stateId",null())),
    value: fv!item.state,
    saveInto: {fv!item.state,
    }
    ),

    Local variables:-

    local!Countries:{
    a!map(countryId:1,country:"India"),
    a!map(countryId:2,country:"USA")
    },
    local!states:{
    a!map(stateId:1,countryId:1,state:"Andhra Pradesh"),
    a!map(stateId:2,countryId:1,state:"Telangana"),
    a!map(stateId:3,countryId:2,state:"Canada")
    },


    Go through the code and follow logic for your code.
    Based on selected country, state choice values will be changed.

    Here wherecontains used to get the index of the match country and from local!states it will get the values based on the index.

    https://appianspace.com/2023/07/03/cascading-drop-down-in-appian/ - If you are unable to understand the code, refer this.