Question
update two records
Hey developers,
I need some help. Can anyone tell me what the problem is with this interface? I cannot update two records using the same button.
a!localVariables(
local!livret: rule!PBY_getLivertByUser(),
local!accounts: rule!PBY_getoccountByUser(),
local!transactionAmount: if(
not(isnull(ri!record['recordType!{4af9711d-c31c-43ce-b28b-448102fcb3db}PBY virementInterne.fields.{16a63de7-fa2e-4180-ae25-b255d12f5d9f}montant'])),
ri!record['recordType!{4af9711d-c31c-43ce-b28b-448102fcb3db}PBY virementInterne.fields.{16a63de7-fa2e-4180-ae25-b255d12f5d9f}montant'],
0
),
local!selectedAccount: index(local!accounts, 1, {}),
local!accountName: local!selectedAccount['recordType!{b37748b2-8103-41ea-8028-2b358e4f229c}PBY account.fields.{ed06f701-2605-4d77-bcbe-b3806b766f9d}Nom'] & " " & local!selectedAccount['recordType!{b37748b2-8103-41ea-8028-2b358e4f229c}PBY account.fields.{cdd08f61-8471-4cc4-960d-99bdc81ed235}prenom'],
local!solde: local!selectedAccount['recordType!{b37748b2-8103-41ea-8028-2b358e4f229c}PBY account.fields.{4a9de4b2-f127-44f1-86d2-21c2a6b2ee2d}Solde'],
local!newBalance: tointeger(local!solde) + tointeger(local!transactionAmount),
a!formLayout(
label: "",
contents: {
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!cardLayout(
contents: {
a!cardLayout(
contents: {
a!sectionLayout(
label: "",
labelColor: "#434343",
contents: {
a!richTextDisplayField(
label: "",
value: {
a!richTextHeader(
text: {
"Ci-dessous, les informations liées Ã%A0 votre livret."
},
size: "LARGE"
)
}
),
a!textField(
label: "montant du livret",
value: local!livret['recordType!{d10768c8-ed65-4122-8d0f-093e83c004bc}PBY livretA.fields.{735e124d-4883-4dbd-b282-5795ca7810cf}Montant'],
readOnly: true
),
a!textField(
label: "Date d'ouverture du livret",
value: todate(local!livret['recordType!{d10768c8-ed65-4122-8d0f-093e83c004bc}PBY livretA.fields.{82ac1de9-1e2e-4fd7-934e-1031afb24bb5}createdOn']),
readOnly: true
)
}
)
},
height: "AUTO",
style: "#d9d9d9",
marginBelow: "STANDARD"
),
a!cardLayout(
contents: {
a!richTextDisplayField(
labelPosition: "COLLAPSED",
value: {
a!richTextItem(
text: {
"Veuillez remplir les informations ci-dessous si vous souhaitez effectuer un virement de votre livret vers un autre compte."
},
style: {
"EMPHASIS"
}
)
}
)
},
height: "AUTO",
style: "INFO",
shape: "ROUNDED",
marginBelow: "STANDARD"
),
a!cardLayout(
contents: {
a!textField(
label: "Nom et prénom du compte",
value: local!accountName,
readOnly: true
),
a!integerField(
label: "Montant",
labelPosition: "ABOVE",
value: ri!record['recordType!{4af9711d-c31c-43ce-b28b-448102fcb3db}PBY virementInterne.fields.{16a63de7-fa2e-4180-ae25-b255d12f5d9f}montant'],
saveInto: {
ri!record['recordType!{4af9711d-c31c-43ce-b28b-448102fcb3db}PBY virementInterne.fields.{16a63de7-fa2e-4180-ae25-b255d12f5d9f}montant'],
local!transactionAmount
},
required: true,
validations: if(
or(
isnull(ri!record['recordType!{4af9711d-c31c-43ce-b28b-448102fcb3db}PBY virementInterne.fields.{16a63de7-fa2e-4180-ae25-b255d12f5d9f}montant']),
todecimal(ri!record['recordType!{4af9711d-c31c-43ce-b28b-448102fcb3db}PBY virementInterne.fields.{16a63de7-fa2e-4180-ae25-b255d12f5d9f}montant']) > todecimal(local!livret['recordType!{d10768c8-ed65-4122-8d0f-093e83c004bc}PBY livretA.fields.{735e124d-4883-4dbd-b282-5795ca7810cf}Montant'])
),
"Le montant doit être inférieur ou égal Ã%A0 " & local!livret['recordType!{d10768c8-ed65-4122-8d0f-093e83c004bc}PBY livretA.fields.{735e124d-4883-4dbd-b282-5795ca7810cf}Montant'] & ".",
null
)
)
},
height: "AUTO",
style: "#cccccc",
marginBelow: "STANDARD"
)
},
height: "AUTO",
style: "TRANSPARENT",
marginBelow: "STANDARD"
)
}
)
}
)
},
buttons: a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Effectuer virement et mettre Ã%A0 jour",
saveInto: {
a!save(
target: local!selectedAccount,
value: a!update(
local!selectedAccount,
'recordType!{b37748b2-8103-41ea-8028-2b358e4f229c}PBY account.fields.{4a9de4b2-f127-44f1-86d2-21c2a6b2ee2d}Solde',
local!newBalance
)
),
a!save(
target: local!livret,
value: a!update(
local!livret,
'recordType!{d10768c8-ed65-4122-8d0f-093e83c004bc}PBY livretA.fields.{735e124d-4883-4dbd-b282-5795ca7810cf}Montant',
local!livret['recordType!{d10768c8-ed65-4122-8d0f-093e83c004bc}PBY livretA.fields.{735e124d-4883-4dbd-b282-5795ca7810cf}Montant'] - local!transactionAmount
)
),
a!writeRecords(
records: {local!selectedAccount, local!livret},
onSuccess: {
a!save(
target: ri!record['recordType!{4af9711d-c31c-43ce-b28b-448102fcb3db}PBY virementInterne.fields.{cd84d837-82c1-428b-a4bc-6b72b133b0e5}createdBy'],
value: loggedInUser()
),
a!save(
target: ri!record['recordType!{4af9711d-c31c-43ce-b28b-448102fcb3db}PBY virementInterne.fields.{b2d0e40c-b5e7-4c26-a359-a27c4a5f6ce4}createdOn'],
value: now()
)
}
)
},
submit: true,
style: "SOLID",
validate: true
)
},
secondaryButtons: {
a!buttonWidget(
label: "Supprimer",
value: true,
saveInto: ri!cancel,
submit: true,
style: "OUTLINE",
validate: false
)
}
)
)
)
