saving data to database

Certified Associate Developer

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

saveInto: { a!localVariables( /* Build one new row per selected partyId (no duplicate prevention) */ local!newRows: if( a!isNullOrEmpty(local!selectedInsuredId), {}, 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 ) ) ) ), /* Perform ONE append to avoid "last save wins" */ if( a!isNullOrEmpty(local!newRows), {}, { a!save(ri!mibReportingCodes, append(ri!mibReportingCodes, local!newRows)), a!save(local!mibCodesValidated, null()), a!save(local!noMibCodesAdded, null()) } ) ) }

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer
    in reply to Stefan Helzle

    saveInto: {
                       a!localVariables(
                         /* Build one new row per selected partyId (no duplicate prevention) */
                         local!newRows: if(
                           a!isNullOrEmpty(local!selectedInsuredId),
                           {},
                           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
                               )
                             )
                           )
                         ),
    
                         /* Perform ONE append to avoid "last save wins" */
                         if(
                           a!isNullOrEmpty(local!newRows),
                           {},
                           {
                             a!save(ri!mibReportingCodes, append(ri!mibReportingCodes, local!newRows)),
                             a!save(local!mibCodesValidated, null()),
                             a!save(local!noMibCodesAdded, null())
                           }
                         )
                       )
                       
                      }

  • 0
    Certified Lead Developer
    in reply to harshithal2027

    So you say that you want to add only one item, even if you select multiple. Correct?

    If yes, what is the foreach doing?

    I really have a hard time following your explanation.

Reply Children