write to db error
I am also facing this issue but I have checked it everywhere like XSD, DB and CDT.every Every where the PK is defined in the right way, I am not getting where I went wrong, can anyone help me with this error.



interface code
a!localVariables(
local!item: 'type!{urn:com:appian:types:SHA}SHA_newList'(),
local!a:{},
local!propertyTypeList: rule!SHA_quertyTogetThePropertyTypeName(),
local!ammenityTypeList: rule!SHA_quertyTogetTheAmmenityType(),
local!neighbourhoodLabels:{"Beauty Salons","Stores","Centers","Hospitals","Subways","Companies"},
local!neighbourhoodAbbreviations:{"Beauty Salons","Stores","Centers","Hospitals","Subways","Companies"},
local!Doc: 'type!{urn:com:appian:types:SHA}SHA_document'(),
local!petsDropDownList: rule!SHA_refPets(),
local!selectedPetsList: if(
rule!FCO_hasValue(ri!pets),
index(
index(ri!pets,
wherecontains(true(), ri!pets.isActive),
null),
"petsIdFk", null()),
{}
),
local!originalArray: a!refreshVariable(
value: local!selectedPetsList,
refreshOnReferencedVarChange: false
),
local!insert,
local!insertCDT,
local!delete,
local!deleteCDT,
local!update,
local!updateCDT,
local!selecteAmmenitysList: if(
rule!FCO_hasValue(ri!ammenities),
index(
ri!ammenities,
"ammenityTypeIdFk",
null()
),
{}
),
local!originalArrayAmmenity: a!refreshVariable(
value: local!selecteAmmenitysList,
refreshOnReferencedVarChange: false
),
local!insertAmmenity,
local!insertCDTAmmenity,
local!deleteAmmenity,
local!deleteCDTAmmenity,
local!updateAmmenity,
local!updateCDTAmmenity,
local!selectedLocation: a!map(
"lat": ri!selectYourLocation.latitude,
"lng": ri!selectYourLocation.longitude
),
{
a!sectionLayout(
contents: {
a!richTextDisplayField(
value:{ a!richTextItem(
text: "Add Property",
size: "LARGE",
style: "STRONG",
color: "#39ff14"
),
a!richTextItem(
text:" "),
a!richTextIcon(
icon: "building",
size: "LARGE",
)
}
)
},
divider: "BELOW"
),
a!sectionLayout(
label: "",
contents: {
a!sideBySideLayout(
items: {
a!sideBySideItem(
item:
a!pickerFieldUsersAndGroups(
label: "Property Owner",
labelPosition: "ABOVE",
placeholder: "Enter the name of the Owner",
maxSelections: 1,
groupFilter:cons!SHA_PROPERTY_OWNER_GROUP,
value: ri!listing.propertyOwner,
saveInto: ri!listing.propertyOwner,
required: true()
)
),
a!sideBySideItem(
item:
a!pickerFieldUsersAndGroups(
label: "Agent Names",
labelPosition: "ABOVE",
placeholder: "Enter the names of the Agents",
maxSelections: 1,
groupFilter: cons!SHA_AGENT_GROUP,
value: ri!agentDetails.agentName,
saveInto: ri!agentDetails.agentName
/*required: true()*/
)
)
}
)
}
),
a!boxLayout(
label: "Property Details",
contents: {
a!sectionLayout(
contents: {
a!sideBySideLayout(
items: {
a!sideBySideItem(
item: a!dropdownField(
label: "Property Type",
placeholder: "Select type of property",
choiceLabels: index(
local!propertyTypeList,
"propertytypenm",
null
),
choiceValues: index(
local!propertyTypeList,
"propertytypeid",
null
),
value: ri!listing.propertyTypeIdFk,
saveInto: ri!listing.propertyTypeIdFk,
required: true
)
),
a!sideBySideItem(
item: a!textField(
label: "Property Name",
placeholder: "Enter the Name of the Property",
value: ri!listing.propertyName,
saveInto: ri!listing.propertyName,
required: true(),
validations: if(regexmatch("^[a-zA-Z ]*$",ri!listing.propertyName),null,"Enter only text")
)
)
}
),
a!sideBySideLayout(
items: {
a!sideBySideItem(
item: a!paragraphField(
label: "Property Description",
placeholder: "Enter the property description",
value: ri!listing.propertyDescription,
saveInto: ri!listing.propertyDescription,
validations: if(regexmatch("^[a-zA-Z ]",ri!listing.propertyDescription),null,"Enter only text")
)
),
a!sideBySideItem(
item: a!dropdownField(
label: "Number of occupancy",
placeholder: "Select Occupancy type",
choiceLabels: cons!SHA_DOUBLE_OCCUPANCY_VALUES,
choiceValues: cons!SHA_DOUBLE_OCCUPANCY_VALUES,
value: ri!listing.doubleOccupancy,
saveInto: ri!listing.doubleOccupancy,
required: true()
)
)
}
)}),
a!sectionLayout(
contents: {
a!sideBySideLayout(
items: {
a!sideBySideItem(
item: a!dropdownField(
label: "Floor Plan Name",
placeholder: "Select a floor plan",
choiceLabels: cons!SHA_FLOORPLANENAMESCONSTANT,
choiceValues: cons!SHA_FLOORPLANENAMESCONSTANT,
value: ri!listing.floorPlanName,
saveInto: ri!listing.floorPlanName,
required: true()
)
),
a!sideBySideItem(
item:
a!multipleDropdownField(
label: "Neighbourhood",
placeholder: "Select neighbourhoods",
choiceLabels:cons!SHA_NEIGHBOURHOOD_TYPES,
choiceValues:cons!SHA_NEIGHBOURHOOD_TYPES,
value:
/*local!a,*/
ri!listing.neighborhood,
saveInto: {local!a,ri!listing.neighborhood}
)
)
}
),
a!sideBySideLayout(
items: {
a!sideBySideItem(
item: a!textField(
label: "Price",
placeholder: "Enter the price of the property",
value: if(
rule!FCO_isNullOrBlank(ri!listing.price),
null,
dollar(ri!listing.price, 2, 0)
),
saveInto: ri!listing.price,
/*validations:{ if(regexmatch("[0-9]",ri!listing.price),null,"Enter only numbers")},*/
required: true()
)
),
a!sideBySideItem(
item: a!textField(
label: "Square FootAge (In Sqft)",
placeholder: "Enter square footage",
value: ri!listing.squareFootage,
saveInto: ri!listing.squareFootage,
required: true()
/*validations: */
/*if(regexmatch("^[0-9]*$",ri!listing.squareFootage),null,"Enter only numbers")*/
)
)
}
),
a!sideBySideLayout(
items: {
a!sideBySideItem(
item: a!dropdownField(
label: "Bed (Rooms)",
placeholder: "Select no of bed(rooms)",
choiceLabels: cons!SHA_BEDROOMLIST,
choiceValues: cons!SHA_BEDROOMLIST,
value: ri!listing.bedRooms,
saveInto: ri!listing.bedRooms,
required: true()
)
),
a!sideBySideItem(
item: a!dropdownField(
label: "Rest Rooms",
placeholder: "Select no of restrooms",
choiceLabels: cons!SHA_BEDROOMLIST,
choiceValues: cons!SHA_BEDROOMLIST,
value: ri!listing.bathRooms,
saveInto: ri!listing.bathRooms,
required: true()
)
)
}
),
a!sideBySideLayout(
items: {
a!sideBySideItem(
item:
a!multipleDropdownField(
label: "Pets",
labelPosition: "ABOVE",
placeholder: "Select pets",
choiceLabels: index(local!petsDropDownList, "petsNm", null),
choiceValues: index(local!petsDropDownList, "petsId", null),
value: local!selectedPetsList,
saveInto: local!selectedPetsList,
searchDisplay: "AUTO",
validations: {}
)),
a!sideBySideItem(
item:
a!multipleDropdownField(
label: "Ammenities",
labelPosition: "ABOVE",
placeholder: "Select ammenities",
choiceLabels: index(
local!ammenityTypeList,
"ammenitytypenm",
null
),
choiceValues: index(
local!ammenityTypeList,
"ammenitytypeid",
null
),
value: { local!selecteAmmenitysList },
saveInto: { local!selecteAmmenitysList },
searchDisplay: "AUTO",
validations: {}
/*required: true()*/
))
})},
divider: "BELOW",
marginBelow: "STANDARD"
),/*Property details*/
a!boxLayout(
label: "Address",
contents: {
a!sideBySideLayout(
items: {
a!sideBySideItem(
item: a!textField(
label: "Address Line 1",
labelPosition: "ABOVE",
placeholder: "Enter property address",
value: ri!addressDetails.addressLine1,
saveInto: ri!addressDetails.addressLine1,
refreshAfter: "UNFOCUS",
characterLimit: 200,
required: true,
validations: {}
)
),
a!sideBySideItem(
item: a!textField(
label: "Address Line 2 (Optional)",
labelPosition: "ABOVE",
placeholder: "Optional",
value: ri!addressDetails.addressLine2,
saveInto: ri!addressDetails.addressLine2,
refreshAfter: "UNFOCUS",
characterLimit: 200,
required: false,
validations: {}
)
)
}
),
a!sideBySideLayout(
items: {
a!sideBySideItem(
item: a!dropdownField(
label: "Province",
placeholder:"Select province",
choiceLabels:cons!SHA_STATESCONSTANT,
choiceValues:cons!SHA_STATESCONSTANT,
value: ri!addressDetails.province,
saveInto: ri!addressDetails.province,
required: true()
/*validations: {*/
/*if(regexmatch("^[a-zA-Z ]*$",ri!addressDetails.province),null,"Enter only text")*/
/*}*/
)
),
a!sideBySideItem(
item: a!dropdownField(
label: "City",
labelPosition: "ABOVE",
placeholder: "Select city",
choiceLabels:rule!SHA_determineCityBasedOnState(input1: ri!addressDetails.province),
choiceValues: rule!SHA_determineCityBasedOnState(input1: ri!addressDetails.province),
value: ri!addressDetails.city,
saveInto: ri!addressDetails.city,
required: true(),
disabled:isnull(ri!addressDetails.province)
)
)
}
),
a!sideBySideLayout(
items: {
a!sideBySideItem(
item: a!textField(
label: "Postal",
labelPosition: "ABOVE",
placeholder: "Enter your postal code",
value: ri!addressDetails.postal,
saveInto: ri!addressDetails.postal,
refreshAfter: "UNFOCUS",
characterLimit: 10,
required: true(),
validations: {
if( len(ri!addressDetails.postal)>=5,
"",
"Invalid Zipcode"
)
}
)
),
a!sideBySideItem(item: {})
}
)
},
style: "#ffebcd",
isCollapsible: true,
marginBelow: "STANDARD"
),
a!boxLayout(
label: "Location",
contents: {
a!sectionLayout(
contents: {
if(
rule!HHC_hasValue(ri!selectYourLocation),
rule!GM_s_mapsDisplay(
selectedLocation: {
lat: ri!selectYourLocation.latitude,
lng: ri!selectYourLocation.longitude,
},
zoomLevel: ri!selectYourLocation.zoomlevel,
locationName: ri!listing.propertyName,
locationDescription: ri!selectYourLocation.locationdescripton,
useWebContent: true
),
rule!GM_c_MapsPlaceSearchAndPin(
selectedLocation: local!selectedLocation,
label: "Pin the Listing Location on Map",
placeholder: "search location... (min. 3 characters)",
isRequired: true()
)
),
a!richTextDisplayField(
labelPosition: "COLLAPSED",
value: {
a!richTextItem(
text: "** Listing location is mandatory to submit the form",
color: "NEGATIVE",
size: "SMALL",
style: "STRONG"
),
char(10),
char(10)
}
)
}
)},
style: "#ffebcd",
isCollapsible: true(),
marginBelow: "STANDARD"
),/*location details*/
a!boxLayout(
label: "Document",
contents: {
rule!SHA_documentinterface(documents: ri!documents),
a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Submit",
value: "Submit",
saveInto: {
ri!buttons,
if(
isnull(ri!listing),
a!save(ri!listing, local!item),
{}
),
a!save(ri!listing.isActive, 1),
a!save(
local!update,
intersection(
tointeger(local!selectedPetsList),
tointeger(local!originalArray)
)
),
/*getting update item*/
a!save(
local!updateCDT,
index(
if(rule!FCO_hasValue(ri!pets), ri!pets, {}),
wherecontains(
tointeger(local!update),
tointeger(
if(
rule!FCO_hasValue(ri!pets),
ri!pets.petsIdFk,
{}
)
)
)
)
),
/*indexing and storing in the updateCDT*/
a!save(
local!delete,
difference(
tointeger(local!originalArray),
tointeger(local!selectedPetsList)
)
),
/*getting deleted item*/
a!save(
local!deleteCDT,
index(
if(rule!FCO_hasValue(ri!pets), ri!pets, {}),
wherecontains(
tointeger(local!delete),
tointeger(
if(
rule!FCO_hasValue(ri!pets),
ri!pets.petsIdFk,
{}
)
)
)
)
),
/*indexing and storing it in the deletedCDT*/
a!save(
local!deleteCDT,
a!forEach(
items: local!deleteCDT,
expression: if(
fv!item.isActive = true(),
'type!{urn:com:appian:types:SHA}SHA_newPets'(
petsId: fv!item.petsId,
listingIdFk: fv!item.listingIdFk,
petsIdFk: fv!item.petsIdFk,
isActive: false,
createdBy: fv!item.createdBy,
createdDate: fv!item.createdDate,
lastUpdatedBy: loggedInUser(),
lastUpdatedDate: now()
),
fv!item
)
)
),
/*creating deleted CDT item*/
a!save(
local!insert,
difference(
tointeger(local!selectedPetsList),
tointeger(local!originalArray)
)
),
/*getting inserted item*/
a!save(
local!insertCDT,
a!forEach(
items: local!insert,
expression: 'type!{urn:com:appian:types:SHA}SHA_newPets'(
petsId: null,
listingIdFk: index(ri!pets, "listingIdFk", null),
petsIdFk: fv!item,
isActive: true,
createdBy: loggedInUser(),
createdDate: now(),
lastUpdatedBy: loggedInUser(),
lastUpdatedDate: now()
)
)
),
/*creating inserted CDT item*/
a!save(
ri!pets,
reject(
fn!isnull,
append(
local!updateCDT,
local!deleteCDT,
local!insertCDT
)
)
),
/*rejecting the null values and appending updateCDT,insertedCDT,deletedCDT */
a!save(
local!updateAmmenity,
intersection(
tointeger(local!selecteAmmenitysList),
tointeger(local!originalArrayAmmenity)
)
),
/*getting update item*/
a!save(
local!updateCDTAmmenity,
index(
if(
rule!FCO_hasValue(ri!ammenities),
ri!ammenities,
{}
),
wherecontains(
tointeger(local!updateAmmenity),
tointeger(
if(
rule!FCO_hasValue(ri!ammenities),
ri!ammenities.ammenityTypeIdFk,
{}
)
)
)
)
),
/*indexing and storing in the updateCDT*/
a!save(
local!deleteAmmenity,
difference(
tointeger(local!originalArrayAmmenity),
tointeger(
if(
rule!FCO_hasValue(ri!ammenities),
local!selecteAmmenitysList,
{}
)
)
)
),
/*getting deleted item*/
a!save(
local!deleteCDTAmmenity,
index(
if(
rule!FCO_hasValue(ri!ammenities),
ri!ammenities,
{}
),
wherecontains(
tointeger(local!deleteAmmenity),
tointeger(
if(
rule!FCO_hasValue(ri!ammenities),
ri!ammenities.ammenityTypeIdFk,
{}
)
)
)
)
),
/*indexing and storing it in the deletedCDT*/
a!save(
local!deleteCDTAmmenity,
a!forEach(
items: local!deleteCDTAmmenity,
expression: 'type!{urn:com:appian:types:SHA}SHA_newAmmenities'(
ammenityId: fv!item.ammenityId,
listingIdFk: fv!item.listingIdFk,
ammenityTypeIdFk: fv!item.ammenityTypeIdFk,
isActive: false,
createdBy: fv!item.createdBy,
createdDate: fv!item.createdDate,
lastUpdatedBy: loggedInUser(),
lastUpdatedDate: now()
)
)
),
/*creating deleted CDT item*/
a!save(
local!insertAmmenity,
difference(
tointeger(local!selecteAmmenitysList),
tointeger(local!originalArrayAmmenity)
)
),
/*getting inserted item*/
a!save(
local!insertCDTAmmenity,
a!forEach(
items: local!insertAmmenity,
expression: 'type!{urn:com:appian:types:SHA}SHA_newAmmenities'(
ammenityId: null,
listingIdFk: index(
if(
rule!FCO_hasValue(ri!ammenities),
ri!ammenities.listingIdFk,
{}
),
1,
null
),
ammenityTypeIdFk: fv!item,
isActive: true,
createdBy: loggedInUser(),
createdDate: now(),
lastUpdatedBy: loggedInUser(),
lastUpdatedDate: now()
)
)
),
/*creating inserted CDT item*/
a!save(
ri!ammenities,
reject(
fn!isnull,
append(
local!updateCDTAmmenity,
local!deleteCDTAmmenity,
local!insertCDTAmmenity
)
)
),
/*rejecting the null values and appending updateCDT,insertedCDT,deletedCDT */
a!save(
ri!selectYourLocation.latitude,
index(local!selectedLocation, "lat", null)
),
a!save(
ri!selectYourLocation.longitude,
index(local!selectedLocation, "lng", null)
),
a!save(ri!selectYourLocation.isactive, 1),
a!save(
ri!selectYourLocation.createddate,
rule!FCO_replaceNull(
ri!selectYourLocation.createddate,
now()
)
),
a!save(
ri!selectYourLocation.createdby,
rule!FCO_replaceNull(
ri!selectYourLocation.createdby,
loggedInUser()
)
),
a!save(
ri!selectYourLocation.updateddate,
now()
),
a!save(
ri!selectYourLocation.updatedby,
loggedInUser()
)
},
submit: if(
rule!FCO_hasValue(local!selectedLocation),
true,
false
),
style: "PRIMARY"
/*showWhen: ri!isEditable*/
)
},
secondaryButtons: {
a!buttonWidget(
label: "Cancel",
value: "Cancel",
saveInto: ri!buttons,
submit: true,
style: "DESTRUCTIVE",
/*showWhen: ri!isEditable,*/
validate: false
)
}
)},
style: "#ffebcd",
isCollapsible: true()
)
},
style: "#ffebcd"
)
})
