saving multiple rows in database

Certified Associate Developer

I have a multiselect dropdown with names h1, h2 and there respective ids are 123,456. the interface is to update the codes in site.But when I am selecting both values from dropdown and adding the code, code is not getting added for both the values. It is only getting added for the first value(h1) which I selected initially in the dropdown(h1)

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer
    update the codes in site

    What exactly do you mean with this?

    Please share more details and code snippets.

  • 0
    Certified Associate Developer
    in reply to Stefan Helzle

    In UI I have option to add data using addRowLink. Once I select one name consider h1, then I click on addRow then there I can write any alphanumeric code and I am storing that in backend. but if I am selecting multiple names(2) then if I click on addRowLink 2 new row boxes are being displayed. In UI even if I select multiple names only one row should be displayed and in backend the code should be updated for all selected names. no submit button is available in that interface

  • 0
    Certified Lead Developer
    in reply to harithab835860

    You're only saving for the first selected value. Use a!forEach() to iterate all selections.
    I think, Your addRowLink is creating rows based on dropdown selection count.
    Instead:
    Don't use dropdown length to determine rows - always show one row regardless of selection
    In your saveInto, loop through all selected Ids

    a!forEach(
         items: local!selectedNameIds,
         expression: a!map(id: fv!item, code: local!codeInput)
       )

    This updates the same code for all selected names in one action

  • 0
    Certified Associate Developer
    in reply to Shubham Aware

    a!forEach(
    items: local!selectedInsuredId,
    expression: a!localVariables(

    local!idx: index(fv!item,
    wherecontains(fv!item, local!insuredParty[partyId]),

    null()
    ),

    recordType(
    appianId:
    index(local!insuredParty[id], local!idx, null()),
    validated: false,
    partyID: fv!item,
    recordType!createdon: now(),
    recordType!createdBy: loggedInUser(),

    )
    )
    )
    ),
    iterating in the same way but 2 rows are getting displayed when 2 names are selected

  • 0
    Certified Lead Developer
    in reply to harithab835860

    Can you please share your full code properly using this.



  • 0
    Certified Associate Developer
    in reply to Shubham Aware

    a!forEach(
    items: local!selectedInsuredId,
    expression: a!localVariables(
    /* Find the index of this party to resolve its applicationId */
    local!idx: index(fv!item,
    wherecontains(fv!item, local!insuredParty['recordType!{f953bbb6-0363-40ce-afe7-4fd0315e1fc0}UWG Party.fields.{19291ea5-16a7-4ddb-9fc9-dbd77b0f9b3e}id']),

    null()
    ),
    /* Construct a new UWG MIB Reporting Code row */
    'recordType!{a705bdd4-5853-4575-bf26-39f58fbcb25a}UWG MIB Reporting Code'(
    'recordType!{a705bdd4-5853-4575-bf26-39f58fbcb25a}UWG MIB Reporting Code.fields.{42e0ad63-0ba5-42bf-bf62-feff961f8d11}applicationId':
    index(local!insuredParty['recordType!{f953bbb6-0363-40ce-afe7-4fd0315e1fc0}UWG Party.fields.{0b7cc71a-9085-4b8d-8173-d3fb2dfcaeed}appianApplicationID'], local!idx, null()),
    'recordType!{a705bdd4-5853-4575-bf26-39f58fbcb25a}UWG MIB Reporting Code.fields.{b7e4ad0f-8daa-4d4e-bdff-38c77b595b2a}mrcIsMibReportingCodeValidated': false,
    'recordType!{a705bdd4-5853-4575-bf26-39f58fbcb25a}UWG MIB Reporting Code.fields.{36931678-bcb8-43ba-abd3-9f09fa9ec90e}partyId': fv!item,
    'recordType!{a705bdd4-5853-4575-bf26-39f58fbcb25a}UWG MIB Reporting Code.fields.{5a73b0fe-cee4-4d8f-b9d5-cc3a7a574644}createdOn': now(),
    'recordType!{a705bdd4-5853-4575-bf26-39f58fbcb25a}UWG MIB Reporting Code.fields.{4ea74402-050f-4d34-b459-3ae196ba1c73}createdBy': loggedInUser(),
    'recordType!{a705bdd4-5853-4575-bf26-39f58fbcb25a}UWG MIB Reporting Code.fields.{da86ac28-b1d2-41c3-ab2b-11af8f8b9c24}updatedOn': now(),
    'recordType!{a705bdd4-5853-4575-bf26-39f58fbcb25a}UWG MIB Reporting Code.fields.{a1ee9757-ddda-4f4c-a659-68c1d6ebbfe8}updatedBy': loggedInUser(),
    'recordType!{a705bdd4-5853-4575-bf26-39f58fbcb25a}UWG MIB Reporting Code.fields.{ed97db33-4b1a-458d-bd65-f33878fa9879}isActive': true
    )
    )
    )
    ),

  • 0
    Certified Associate Developer
    in reply to Shubham Aware

    I wasnot able to share code. when I am pasting the actual code It is being determined as spam

Reply Children
No Data