Hi!
I'm new to Appian records, been working with a really outdated version until now.
I'm trying to do a sort of properties interface where a user can add new values into properties but I can't seem to make a new row of records, here's the code
a!localVariables( local!properties:rule!MM_getPropertiesByType(type: ri!propertyType), local!addAux, { a!gridLayout( label: ri!propertiesLiteral, labelPosition: "ABOVE", headerCells: { a!gridLayoutHeaderCell(label: ""), a!gridLayoutHeaderCell(label: "Value"), a!gridLayoutHeaderCell(label: "") }, columnConfigs: { a!gridLayoutColumnConfig( width: "ICON" ), a!gridLayoutColumnConfig( weight: 10 ), a!gridLayoutColumnConfig( width: "ICON" ) }, rows: { a!gridRowLayout( contents: { a!richTextDisplayField( labelPosition: "COLLAPSED", value: { a!richTextIcon( icon: "arrow-up" ), a!richTextIcon( icon: "arrow-down" ) } ), a!textField( value: local!properties.value, saveInto:{ local!properties.value /*a!save(*/ /*'recordType!{5ebb976a-556f-4033-b1d7-9e5976ab963d}MM Property',*/ /*'recordType!{5ebb976a-556f-4033-b1d7-9e5976ab963d}MM Property'.(*/ /*'recordType!{5ebb976a-556f-4033-b1d7-9e5976ab963d}MM Property.fields.{041a7f43-dfd1-4b07-aaed-48e305712f4e}value':local!properties.value,*/ /*'recordType!{5ebb976a-556f-4033-b1d7-9e5976ab963d}MM Property.fields.{54637987-ef12-4057-b4c3-c898561cb626}type':ri!propertyType,*/ /*'recordType!{5ebb976a-556f-4033-b1d7-9e5976ab963d}MM Property.fields.{832f6a1b-9643-4fd5-a389-0556c2ee74a6}order':fv!index,*/ /*'recordType!{5ebb976a-556f-4033-b1d7-9e5976ab963d}MM Property.fields.{2612aa2c-ca09-4a4f-87a1-f66b6f08303c}modifiedOn':now(),*/ /*'recordType!{5ebb976a-556f-4033-b1d7-9e5976ab963d}MM Property.fields.{39dea2b9-c9f9-4b57-9aeb-62cf86ab5656}createdBy':loggedInUser(),*/ /*'recordType!{5ebb976a-556f-4033-b1d7-9e5976ab963d}MM Property.fields.{18bf5c84-4f3f-4566-a572-6d8ba5dd5285}active':true*/ /*)*/ /*)*/ } ), a!richTextDisplayField( labelPosition: "COLLAPSED", value: { a!richTextIcon( icon: "check" ), " ", a!richTextIcon( icon: "times" ) } ) } ) }, shadeAlternateRows: true, addRowLink:a!dynamicLink( label: "Add", saveInto: { a!save( local!properties, append(local!properties,'recordType!{5ebb976a-556f-4033-b1d7-9e5976ab963d}MM Property') ) } ) ) } )
Can someone explain how I might do this?
with this code when I try to add a row i get this: "Interface Definition: Expression evaluation error [evaluation ID = 8VMFS] : An error occurred while executing a save: Expression evaluation error at function 'append' [line 75]: Could not cast from RecordType to MM Property. Details: CastInvalid"
Thank you
Discussion posts and replies are publicly visible
Try this tweak in your append() call-
append( local!properties, 'recordType![typename]'())
The point is we want to have it give you an "empty copy" of a record - that requires it to be called like a type constructor (hence the empty "()" at the end), because without that, it's just a reference to the type itself i guess, as opposed to an actual instance of that type.
Should be a small change, you just need to change line 76 to include parentheses to define a record data type like this:
a!save( local!properties, append(local!properties,'recordType!{5ebb976a-556f-4033-b1d7-9e5976ab963d}MM Property'()) )
The key difference is if you don't include the parentheses, it just is a reference to the record type. If you do include the parentheses, it now defines a variable with that type that can be used in expressions. It's the difference between a Record Type and a Record Data Type in this documentation page: docs.appian.com/.../Appian_Data_Types.html
feels like there's an echo in here
Ha looks like I should have refreshed before posting
thank you both