I am getting below error::
Interface Definition: Expression evaluation error at function a!textField [line 56]: Invalid index: Cannot index property 'shippingAddress' of type Text into type
Boolean
My code is:
a!localVariables(
local!locationsList: rule!AIP_getAddress(addressId: NULL),
local!addingAddress : false(),
local!newAddress : 'type!{urn:com:appian:types:AIP}AIP_address'(),
{
a!sectionLayout(
label: "Address",
contents: {
a!radioButtonField(
label: "Radio Buttons",
labelPosition: "COLLAPSED",
choiceLabels:
a!forEach(
items: local!locationsList,
expression: fv!item.shippingAddress & " " &
if(isnull(fv!item.unitNumber), null, "Unit #" & fv!item.unitNumber)
& " " & fv!item.city & ", " & fv!item.stateOrProvince & " "
& fv!item.postalCode
),
choiceValues: local!locationsList,
value: ri!address,
saveInto: ri!address,
choiceLayout: "STACKED",
validations: {}
)
}
a!richTextDisplayField(
value: {
a!richTextIcon(
icon: "plus"
" ",
a!richTextItem(
text: {
"Add New Address"
},
link: a!dynamicLink(
label: "Dynamic Link",
value: true(),
saveInto: local!addingAddress
style: {
"STRONG"
a!boxLayout(
label: "Add New Address",
a!sideBySideLayout(
items: {
a!sideBySideItem(
item: a!textField(
label: "Shipping Address",
labelPosition: "ABOVE",
value: local!newAddress.shippingAddress,
saveInto: local!newAddress.shippingAddress,
refreshAfter: "UNFOCUS",
required: true,
label: "Unit number",
value: local!newAddress.unitNumber,
saveInto: local!newAddress. unitNumber,
label: "City",
value: local!newAddress.city,
saveInto: local!newAddress.city,
width: "2X"
label: "State/Province",
value: local!newAddress,
saveInto: local!newAddress,
width: "1X"
label: "Postal Code",
a!buttonArrayLayout(
buttons: {
a!buttonWidget(
label: "ADD",
saveInto: {
a!save(local!locationsList,append(local!locationsList,local!newAddress)),
a!save(ri!address,local!newAddress),
a!save(local!newAddress,{addreessId: null,shippingAddress:" ",unitNumber:null,city:" ",
stateOrProvince: " ",postalCode : null}),
a!save(local!addingAddress,false())
style: "PRIMARY",
validate: true
align: "END"
showWhen: local!addingAddress,
style: "ACCENT",
marginBelow: "STANDARD"
I have attached the screenshot for reference . Kindly guide me please.
Discussion posts and replies are publicly visible
Hi , From the code , it looks like you are not using correct indexes in your text fields. Try to fix the index, something like below
a!sideBySideItem( item: a!textField( label: "Postal Code", labelPosition: "ABOVE", value: local!newAddress.postalCode, saveInto:local!newAddress.postalCode, refreshAfter: "UNFOCUS", required: true, validations: {} )
I have tried the same way as you mentioned. You can check on my code as well.
Hi pd0001 , I am not able to see your CDT structure . from the error looks like you are trying to index text field into boolean field. Did you check what value local!newAddress is having . i think you need to refresh your interface
Hi there,
Cast the value to a string before saving it in the variable. That should resolve the issue.
If possible ,can u give a example with code?
yes it is storing boolean . Not sure why it is storing boolean because i have not initialized my local!newAddress with boolean.
you can use a!map also to intialize the local variable or just use rule input itself.
Hi,
try using index function like in index(local!newAddress,"shippingAddress",null)
https://docs.appian.com/suite/help/21.4/fnc_array_index.html
In CDT 'type!{urn:com:appian:types:AIP}AIP_address'(), you might have declared shipping Address as boolean,please check it