Hi, I have been experiencing an issue where I am trying to save the v

Hi,

I have been experiencing an issue where I am trying to save the values that are calculated automatically in an inline editable grid but they are not being saved in a variable. I've tried using all the functions to save those values but they're not getting saved anywhere.

for example, If I calculate amount through quantity*price then quantity and price are getting saved but not the Amount.

a!textField(
label: "amount " & ri!index,
align: "RIGHT",
readOnly: true,
value: if(or(isnull(ri!items[ri!index].qty), isnull(ri!items[ri!index].unitPrice)), null,
dollar(tointeger(ri!items[ri!index].qty) * todecimal(ri!items[ri!index].unitPrice))),
saveInto: ri!items[ri!index].amount
)

So Can anyone help me saving auto-populated values in a grid?

Thanks,
Varnika

OriginalPostID-209066

OriginalPostID-209066

  Discussion posts and replies are publicly visible

  • you can calculate amount from saveInto of quantity and price. something like below

    a!save(ri!items[ri!index].amount, if(or(isnull(ri!items[ri!index].quantity),
    isnull(ri!items[ri!index].price )),{},(ri!items[ri!index].quantity*ri!items[ri!index].price)))

    instead of putting, if condition on value attribute of Amount field
  • I can't use a!save as it's not supported by Appian 7.5
  • @varnikam One way to resolve this is to push the values into 'amount' field in the 'saveInto' of 'quantity' and 'price' provided if you are going to interact with quantity and price fields for sure.

    And with regards to behavior, yes, that's an expected behavior. You can't save values into a variable until and unless you interact with a component and that's how SAIL works. That is, you can't save the values into 'amount' until and unless you interact with it. At a high level I understand that 'amount' is a field used for display purpose, and that's why I have been suggesting to update the 'amount' field's value when you interact with other fields namely 'quantity' and 'price'.
  • To the best of my knowledge, there isn't a problem, even if you are not able to make use of a!save(). Still you would be able to perform the save operations as we can do in the latest versions, but the difference is that we would be using a SAVE operator and in order to save values into multiple variables you may want to go through the documentation at forum.appian.com/.../SAIL_Design.

    Please do let us know if you have any follow-up questions or if the comments made didn't answer your post.
  • Sikhivahans, Thank you for your responses. As you've suggested to save the amount in to save into function of the expression used for price, I tried to incorporate the same functionality but that didn't work -

    Here is the expression I used to save the amount :

    a!integerField(
    label: "qty " & ri!index,
    align: "RIGHT",
    validations: if(tointeger(ri!items[ri!index].qty) < 1, "Quantity must be greater than 0", null),
    value: ri!items[ri!index].qty,
    saveInto: ri!items[ri!index].qty
    ),
    a!floatingPointField(
    label: "unitPrice " & ri!index,
    align: "RIGHT",
    validations: if(todecimal(ri!items[ri!index].unitPrice) < 1, "Unit price must be greater than 0", null),
    value: ri!items[ri!index].unitPrice,
    saveInto: {ri!items[ri!index].unitPrice, ri!items[ri!index].amount << fn!append(ri!items[ri!index].unitPrice*ri!items[ri!index].qty, _)}
    )

    Do you have any example that I can use to save the value?

    Thanks,
    Varnika

  • Please try below snippet.
    ri!items[ri!index].amount <<( ri!items[ri!index].unitPrice*ri!items[ri!index].qty)
  • Varnika, would you please be able to test the following code and do let me know how things are going?

    a!integerField(
    label: "qty " & ri!index,
    align: "RIGHT",
    validations: if(tointeger(ri!items[ri!index].qty) < 1, "Quantity must be greater than 0", null),
    value: ri!items[ri!index].qty,
    saveInto: {
                        ri!items[ri!index].qty,
                        ri!items[ri!index].amount << rule!APN_returnFirstInput(
                                  if(or(isnull(ri!items[ri!index].quantity),isnull(ri!items[ri!index].price )),null,ri!items[ri!index].quantity*ri!items[ri!index].price),
                                  _
                        )
               }
    ),
    a!floatingPointField(
               label: "unitPrice " & ri!index,
    align: "RIGHT",
    validations: if(todecimal(ri!items[ri!index].unitPrice) < 1, "Unit price must be greater than 0", null),
    value: ri!items[ri!index].unitPrice,
    saveInto: {
                        ri!items[ri!index].unitPrice,
                        ri!items[ri!index].amount << rule!APN_returnFirstInput(
                                  if(or(isnull(ri!items[ri!index].quantity),isnull(ri!items[ri!index].price )),null,ri!items[ri!index].quantity*ri!items[ri!index].price),
                                  _
                        )
               }
    )
  • Sikhivahans, thanks for the post but this didn't work either. I believe this is a drawback of SAIL that we can't store the values in SAIL down unless we are not interacting with it.

    Thanks for the help,
    Varnika
  • @varnikam To the best of my knowledge, that assumption isn't correct as we generally save the values of the read only variables under other components and it is because of the fact that a SAIL component's value can't be changed until and unless it is interacted with or updated in an other component's saveInto. It would be grateful if you can attach the code snippet so that the practitioners here can give you suggestions.