write data back to Database from Interface

Hi All,

am new to Appian, i have developed the Interface to fetch master values from Database, show it in a grid for adding or updating the data, please help me how can write the updated or added data back to Database,

Sorry, the Insert Code link is not working, so i have pasted my code below.

load(
a!localVariables(
local!type: cast('type!{urn:com:appian:types:LMP}LMP_REF_TYPES?list',
rule!LMP_getTypesListByFilters(
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: - 1,
sort: a!sortInfo(
field: "abbreviation",
ascending: true()
)
)
)
),
local!sbgList: rule!LMP_getREFTableDetailsAdmin(
MasterRef: "SBG"
),
local!regionList: rule!LMP_getREFTableDetailsAdmin(
MasterRef: "Region"
),
local!FunctionList: rule!LMP_getREFTableDetailsAdmin(
MasterRef: "Function"
),

local!AllValuesMaster: rule!LMP_getAllValuesMasterFilters(
typeid: ri!typeValueSelected,
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: - 1,
sort: a!sortInfo(
field: "description",
ascending: true()
)
)
),
local!SbgSbuMapValues :fn!cast('type!{urn:com:appian:types:LMP}LMP_MAP_SBG_SBU_Master?list',
rule!LMP_getSBUDetailsAdmin(
)
),
local!SBGFunctionMapValues: rule!LMP_getFunctionSBGMappingDetails(

),
local!SBGDemographics: rule!LMP_MAP_DemographicsAdmin(
DemographicMapName: "SBG",
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: - 1,
sort: a!sortInfo(
field: "sbgid",
ascending: true()
)
)
),
local!RegionDemographics: rule!LMP_MAP_DemographicsAdmin(
DemographicMapName: "Region",
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: - 1,
sort: a!sortInfo(
field: "regionid",
ascending: true()
)
)
),
local!FunctionDemographics: rule!LMP_MAP_DemographicsAdmin(
DemographicMapName: "Function",
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: - 1,
sort: a!sortInfo(
field: "functionid",
ascending: true()
)
)
),
local!value: {1,2,5,6,7,8,9,11,12,13,14,15,16},
{
a!sectionLayout(
contents: {
a!columnsLayout(
columns:{
a!columnLayout(
contents:{
a!richTextDisplayField(
value: {
a!richTextIcon(
icon: "map",
size: "LARGE"
),
a!richTextItem(
text: " Geography/Review",
size: "LARGE"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "Regions",
link: a!dynamicLink(
value: true(),
saveInto: {
a!save(ri!typeValueSelected,cons!LMP_REF_IDS_Types[1])
}
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Major geographic regions",
color: "SECONDARY",
size: "SMALL"
)

}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "Country",
link: a!dynamicLink(
value: true(),
saveInto: {
a!save(ri!typeValueSelected,cons!LMP_REF_IDS_Types[11])
}
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Countries in which Honeywell operates",
color: "SECONDARY",
size: "SMALL"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "Band",
link: a!dynamicLink(
value: true(),
saveInto: {
a!save(ri!typeValueSelected,cons!LMP_REF_IDS_Types[14])
}
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Eligible Employees Band",
color: "SECONDARY",
size: "SMALL"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "Rating",
link: a!dynamicLink(
value: true(),
saveInto: {
a!save(ri!typeValueSelected,cons!LMP_REF_IDS_Types[7])
}
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Eligible Rating for Nomination",
color: "SECONDARY",
size: "SMALL"
)
}
)
},
width: "MEDIUM"
),
a!columnLayout(
contents:{
a!richTextDisplayField(
value: {
a!richTextIcon(
icon: "sitemap",
size: "LARGE"
),
a!richTextItem(
text: " Organization",
size: "LARGE"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "SBG",
link: a!dynamicLink(
value: true(),
saveInto: {
a!save(ri!typeValueSelected,cons!LMP_REF_IDS_Types[2])
}
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Strategic Business Group",
color: "SECONDARY",
size: "SMALL"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "SBU",
link: a!dynamicLink(
value: {
true(),
},
saveInto:a!save(ri!typeValueSelected,cons!LMP_REF_IDS_Types[3])
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Strategic Business Unit",
color: "SECONDARY",
size: "SMALL"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "Function",
link: a!dynamicLink(
value: true(),
saveInto: {
a!save(ri!typeValueSelected,cons!LMP_REF_IDS_Types[10])
}
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Mode of Work Area",
color: "SECONDARY",
size: "SMALL"
)
}
)
},
width: "NARROW_PLUS"
),
a!columnLayout(
contents:{
a!richTextDisplayField(
value: {
a!richTextItem(
text: {
a!richTextIcon(
icon: "address-book"
),
"Employee"
},
size: "LARGE"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "9BlockRating",
link: a!dynamicLink(
value: true(),
saveInto: a!save(ri!typeValueSelected,cons!LMP_REF_IDS_Types[15])
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Yearly Review Rating",
color: "SECONDARY",
size: "SMALL"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "JOB Function",
link: a!dynamicLink(
value: true(),
saveInto: a!save(ri!typeValueSelected,cons!LMP_REF_IDS_Types[6])
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Functional Area",
color: "SECONDARY",
size: "SMALL"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "Program",
link: a!dynamicLink(
value: true(),
saveInto: a!save(ri!typeValueSelected,cons!LMP_REF_IDS_Types[16])
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Programs organised yearly",
color: "SECONDARY",
size: "SMALL"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "Potential Rating",
link: a!dynamicLink(
value: true(),
saveInto: a!save(ri!typeValueSelected,cons!LMP_REF_IDS_Types[13])
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Promotion Criteria",
color: "SECONDARY",
size: "SMALL"
)
}
),
/*a!richTextDisplayField(*/
/*value: {*/
/*a!richTextItem(*/
/*text: "Succession",*/
/*link: a!dynamicLink(*/
/*value: true(),*/
/*saveInto: local!showSuccession*/
/*),*/
/*size: "MEDIUM"*/
/*),*/
/*a!richTextItem(*/
/*text: char(*/
/*10*/
/*) & "NA",*/
/*color: "SECONDARY",*/
/*size: "SMALL"*/
/*)*/
/*}*/
/*),*/
a!richTextDisplayField(
value: {
a!richTextItem(
text: "Ethnicity",
link: a!dynamicLink(
value: true(),
saveInto: a!save(ri!typeValueSelected,cons!LMP_REF_IDS_Types[5])
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "NA",
color: "SECONDARY",
size: "SMALL"
)
}
)

}
),
a!columnLayout(
contents:{
a!richTextDisplayField(
value: {
a!richTextItem(
text: {
a!richTextIcon(
icon: "users"
),
" Demographic"
},
size: "LARGE"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "Demographics",
link: a!dynamicLink(
value: true(),
saveInto: a!save(ri!typeValueSelected,cons!LMP_REF_IDS_Types[8])
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Demographics Master Value",
color: "SECONDARY",
size: "SMALL"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "SBG Demographics",
link: a!dynamicLink(
value: true(),
saveInto: a!save(ri!typeValueSelected,20)
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Mapping of Demographics and SBG",
color: "SECONDARY",
size: "SMALL"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "Function Demographics",
link: a!dynamicLink(
value: true(),
saveInto: a!save(ri!typeValueSelected,22)
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Mapping of Demographics and Function",
color: "SECONDARY",
size: "SMALL"
)
}
),
a!richTextDisplayField(
value: {
a!richTextItem(
text: "Region Demographics",
link: a!dynamicLink(
value: true(),
saveInto: a!save(ri!typeValueSelected,21)
),
size: "MEDIUM"
),
a!richTextItem(
text: char(
10
) & "Mapping of Demographics and Region",
color: "SECONDARY",
size: "SMALL"
)
},
width: "MEDIUM"
)
}

)

}
)
}
),
a!sectionLayout(
contents: {
a!boxLayout(
label: if(or(isnull(ri!typeValueSelected),ri!typeValueSelected = 0),
"Type",
rule!LMP_getTypesListByFilters(
typeid: ri!typeValueSelected
).description),
contents: {
a!gridLayout(
label: "",
headerCells: {
/*a!gridLayoutHeaderCell(*/
/*label: "TypeId"*/
/*),*/
/*a!gridLayoutHeaderCell(*/
/*label: "Abbreviation"*/
/*),*/
a!gridLayoutHeaderCell(
label: "Name"
),
a!gridLayoutHeaderCell(
label: "Active"
),
a!gridLayoutHeaderCell(
label: ""
),
a!gridLayoutHeaderCell(
label: ""
)

},
columnConfigs: {
/*a!gridLayoutColumnConfig(*/
/*width: "ICON"*/
/*),*/
/*a!gridLayoutColumnConfig(),*/
a!gridLayoutColumnConfig(),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
)
},
rows: a!forEach(
items: local!AllValuesMaster,
expression: a!gridRowLayout(
contents: {
/*a!textField(*/
/*value: fv!item.typeid,*/
/*saveInto: fv!item.typeid*/
/*),*/
/*a!textField(*/
/*value: fv!item.abbreviation,*/
/*saveInto: fv!item.abbreviation*/
/*),*/
a!textField(
value: fv!item.description,
saveinto: fv!item.description
),
a!checkboxField(
label: "gbe-active",
choiceLabels: {
""
},
choiceValues: {
true()
},
value: if(
or(
isnull(
fv!item.activein
),
not(
fv!item.activein
)
),
null,
toboolean(
fv!item.activein
)
),
saveInto: {
a!save(
fv!item.activein,
if(
isnull(
save!value
),
false(),
save!value
)
)

},
align: "CENTER"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_UP"
),
altText: "Up",
caption: "Move Up ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = 1,
{},
{
a!save(
local!AllValuesMaster,
insert(
local!AllValuesMaster,
fv!item,
fv!index - 1
)
),
a!save(
local!AllValuesMaster,
remove(
local!AllValuesMaster,
fv!index + 1
)
)
}
)
}
)
),
size: "ICON"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_DOWN"
),
altText: "Down",
caption: "Move Down ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = count(
local!AllValuesMaster
),
{},
{
a!save(
local!AllValuesMaster,
insert(
local!AllValuesMaster,
fv!item,
fv!index + 2
)
),
a!save(
local!AllValuesMaster,
remove(
local!AllValuesMaster,
fv!index
)
)
}
)
}
)
),
size: "ICON"
)
}
)
),
addRowLink: a!dynamicLink(
label: "Add " & if(or(isnull(ri!typeValueSelected),ri!typeValueSelected = 0),
"Type",
rule!LMP_getTypesListByFilters(
typeid: ri!typeValueSelected
).description),
saveInto: a!save(
local!type,
append(
local!type,
'type!{urn:com:appian:types:LMP}LMP_REF_TYPES'(
activein: true()
)
)
)
),
shadeAlternateRows: true
/*paginginfo: a!pagingInfo(*/
/*startIndex: 1,*/
/*batchSize: -1,*/
/*sort: a!sortInfo(*/
/*field: "abbreviation",*/
/*ascending: true()*/
/*)*/
/*)*/
),
a!buttonLayout(
primaryButtons: a!buttonWidget(
label: "Submit",
submit: true,
value: cons!LMP_BUTTON_VALUES[5],
saveInto: ri!ButtonValueALL
),
secondaryButtons: a!buttonWidget(
label: "Cancel",
style: "DESTRUCTIVE",
submit: true,
value: cons!LMP_BUTTON_VALUES[7],
saveInto: ri!ButtonValueALL
)
)

},
showWhen: contains(local!value, ri!typeValueSelected)

),
a!boxLayout(
label: "SBU",
contents: {
a!gridLayout(
label: "",
headerCells: {
a!gridLayoutHeaderCell(
label: "SBU"
),
a!gridLayoutHeaderCell(
label: "SBG"
),
a!gridLayoutHeaderCell(
label: "Active"
),
a!gridLayoutHeaderCell(
label: ""
),
a!gridLayoutHeaderCell(
label: ""
)

},
columnConfigs: {
/*a!gridLayoutColumnConfig(*/
/*width: "ICON"*/
/*),*/
/*a!gridLayoutColumnConfig(),*/
a!gridLayoutColumnConfig(),
a!gridLayoutColumnConfig(),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
)
},
rows: a!forEach(
items: local!SbgSbuMapValues,
expression: a!gridRowLayout(
contents: {

a!textField(
value: fv!item.sbudescription,
saveinto: fv!item.sbudDescription
),
/*a!textField(*/
/*value: fv!item.sbgdescription,*/
/*saveinto: fv!item.sbgdescription*/
/*),*/
a!dropdownField(
label: "",
placeholderLabel: "--- Select a Value ---",
choiceLabels: {
local!sbgList.description
},
choiceValues: {
local!sbgList.sbgid
},
value:fv!item.sbgid,
saveInto:fv!item.sbgid,
validations: {}

),
a!checkboxField(
label: "gbe-active",
choiceLabels: {
""
},
choiceValues: {
true()
},
value: if(
or(
isnull(
fv!item.activein
),
not(
fv!item.activein
)
),
null,
toboolean(
fv!item.activein
)
),
saveInto: {
a!save(
fv!item.activein,
if(
isnull(
save!value
),
false(),
save!value
)
)

},
align: "CENTER"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_UP"
),
altText: "Up",
caption: "Move Up ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = 1,
{},
{
a!save(
local!SbgSbuMapValues,
insert(
local!SbgSbuMapValues,
fv!item,
fv!index - 1
)
),
a!save(
local!SbgSbuMapValues,
remove(
local!SbgSbuMapValues,
fv!index + 1
)
)
}
)
}
)
),
size: "ICON"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_DOWN"
),
altText: "Down",
caption: "Move Down ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = count(
local!SbgSbuMapValues
),
{},
{
a!save(
local!SbgSbuMapValues,
insert(
local!SbgSbuMapValues,
fv!item,
fv!index + 2
)
),
a!save(
local!SbgSbuMapValues,
remove(
local!SbgSbuMapValues,
fv!index
)
)
}
)
}
)
),
size: "ICON"
)
}
)
),
addRowLink: a!dynamicLink(
label: "Add " & if(or(isnull(ri!typeValueSelected),ri!typeValueSelected = 0),
"Type",
rule!LMP_getTypesListByFilters(
typeid: ri!typeValueSelected
).description),
saveInto: a!save(
local!SbgSbuMapValues,
append(
local!SbgSbuMapValues,
'type!{urn:com:appian:types:LMP}LMP_MAP_SBG_SBU_Master'(
activein: true()
)
)
)
),
shadeAlternateRows: true
/*paginginfo: a!pagingInfo(*/
/*startIndex: 1,*/
/*batchSize: -1,*/
/*sort: a!sortInfo(*/
/*field: "abbreviation",*/
/*ascending: true()*/
/*)*/
/*)*/
),
a!buttonLayout(
primaryButtons: a!buttonWidget(
label: "Submit",
submit: true,
value: cons!LMP_BUTTON_VALUES[5],
saveInto: ri!ButtonValueSBU
),
secondaryButtons: a!buttonWidget(
label: "Cancel",
style: "DESTRUCTIVE",
submit: true,
value: cons!LMP_BUTTON_VALUES[7],
saveInto: ri!ButtonValueSBU
)
)

},
showWhen:if(ri!typeValueSelected = 3, true, false)

),
a!boxLayout(
label: "Function",
contents: {
a!gridLayout(
label: "",
headerCells: {
a!gridLayoutHeaderCell(
label: "Function"
),
a!gridLayoutHeaderCell(
label: "SBG"
),
a!gridLayoutHeaderCell(
label: "Active"
),
a!gridLayoutHeaderCell(
label: ""
),
a!gridLayoutHeaderCell(
label: ""
)

},
columnConfigs: {
/*a!gridLayoutColumnConfig(*/
/*width: "ICON"*/
/*),*/
/*a!gridLayoutColumnConfig(),*/
a!gridLayoutColumnConfig(),
a!gridLayoutColumnConfig(),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
)
},
rows: a!forEach(
items: local!SBGFunctionMapValues,
expression: a!gridRowLayout(
contents: {

a!textField(
value: fv!item.functiondescription,
saveinto: fv!item.functiondescription
),
a!dropdownField(
label: "",
placeholderLabel: "--- Select a Value ---",
choiceLabels: {
local!sbgList.description
},
choiceValues: {
local!sbgList.sbgid
},
value:fv!item.sbgid,
saveInto:fv!item.sbgdescription,
validations: {}

),
a!checkboxField(
label: "gbe-active",
choiceLabels: {
""
},
choiceValues: {
true()
},
value: if(
or(
isnull(
fv!item.activein
),
not(
fv!item.activein
)
),
null,
toboolean(
fv!item.activein
)
),
saveInto: {
a!save(
fv!item.activein,
if(
isnull(
save!value
),
false(),
save!value
)
)

},
align: "CENTER"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_UP"
),
altText: "Up",
caption: "Move Up ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = 1,
{},
{
a!save(
local!SBGFunctionMapValues,
insert(
local!SBGFunctionMapValues,
fv!item,
fv!index - 1
)
),
a!save(
local!SBGFunctionMapValues,
remove(
local!SBGFunctionMapValues,
fv!index + 1
)
)
}
)
}
)
),
size: "ICON"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_DOWN"
),
altText: "Down",
caption: "Move Down ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = count(
local!SBGFunctionMapValues
),
{},
{
a!save(
local!SBGFunctionMapValues,
insert(
local!SBGFunctionMapValues,
fv!item,
fv!index + 2
)
),
a!save(
local!SBGFunctionMapValues,
remove(
local!SBGFunctionMapValues,
fv!index
)
)
}
)
}
)
),
size: "ICON"
)
}
)
),
addRowLink: a!dynamicLink(
label: "Add " & if(or(isnull(ri!typeValueSelected),ri!typeValueSelected = 0),
"Type",
rule!LMP_getTypesListByFilters(
typeid: ri!typeValueSelected
).description),
saveInto: a!save(
local!SBGFunctionMapValues,
append(
local!SBGFunctionMapValues,
'type!{urn:com:appian:types:LMP}LMP_MAP_SBG_FUNCTION'(
activein: true()
)
)
)
),
shadeAlternateRows: true
/*paginginfo: a!pagingInfo(*/
/*startIndex: 1,*/
/*batchSize: -1,*/
/*sort: a!sortInfo(*/
/*field: "abbreviation",*/
/*ascending: true()*/
/*)*/
/*)*/
),
a!buttonLayout(
primaryButtons: a!buttonWidget(
label: "Submit",
submit: true,
value: cons!LMP_BUTTON_VALUES[5],
saveInto: ri!ButtonValueFunction
),
secondaryButtons: a!buttonWidget(
label: "Cancel",
style: "DESTRUCTIVE",
submit: true,
value: cons!LMP_BUTTON_VALUES[7],
saveInto: ri!ButtonValueFunction
)
)

},
showWhen: if(ri!typeValueSelected = 10, true, false)

),
a!boxLayout(
label: "SBG-Demographic",
contents: {
a!gridLayout(
label: "",
headerCells: {
a!gridLayoutHeaderCell(
label: "Demographic"
),
a!gridLayoutHeaderCell(
label: "SBG"
),
a!gridLayoutHeaderCell(
label: "Active"
),
a!gridLayoutHeaderCell(
label: ""
),
a!gridLayoutHeaderCell(
label: ""
)

},
columnConfigs: {
/*a!gridLayoutColumnConfig(*/
/*width: "ICON"*/
/*),*/
/*a!gridLayoutColumnConfig(),*/
a!gridLayoutColumnConfig(),
a!gridLayoutColumnConfig(),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
)
},
rows: a!forEach(
items: local!SBGDemographics,
expression: a!gridRowLayout(
contents: {

a!textField(
value: index(cons!LMP_REF_VALUES_DEMOGRAPHICS,fv!item.demographicid, null),
saveinto: fv!item.demographicid
),
/*a!textField(*/
/*value: fv!item.sbgdescription,*/
/*saveinto: fv!item.sbgdescription*/
/*),*/
a!dropdownField(
label: "",
placeholderLabel: "--- Select a Value ---",
choiceLabels: {
local!sbgList.description
},
choiceValues: {
local!sbgList.sbgid
},
value:fv!item.sbgid,
saveInto:fv!item.sbgid,
validations: {}

),
a!checkboxField(
label: "gbe-active",
choiceLabels: {
""
},
choiceValues: {
true()
},
value: if(
or(
isnull(
fv!item.activein
),
not(
fv!item.activein
)
),
null,
toboolean(
fv!item.activein
)
),
saveInto: {
a!save(
fv!item.activein,
if(
isnull(
save!value
),
false(),
save!value
)
)

},
align: "CENTER"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_UP"
),
altText: "Up",
caption: "Move Up ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = 1,
{},
{
a!save(
local!SBGDemographics,
insert(
local!SBGDemographics,
fv!item,
fv!index - 1
)
),
a!save(
local!SBGDemographics,
remove(
local!SBGDemographics,
fv!index + 1
)
)
}
)
}
)
),
size: "ICON"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_DOWN"
),
altText: "Down",
caption: "Move Down ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = count(
local!SBGDemographics
),
{},
{
a!save(
local!SBGDemographics,
insert(
local!SBGDemographics,
fv!item,
fv!index + 2
)
),
a!save(
local!SBGDemographics,
remove(
local!SBGDemographics,
fv!index
)
)
}
)
}
)
),
size: "ICON"
)
}
)
),
addRowLink: a!dynamicLink(
label: "Add SBG-Demographic Mapping",
saveInto: a!save(
local!SBGDemographics,
append(
local!SBGDemographics,
'type!{urn:com:appian:types:LMP}LMP_Map_SBG_Demographic'(
activein: true()
)
)
)
),
shadeAlternateRows: true
/*paginginfo: a!pagingInfo(*/
/*startIndex: 1,*/
/*batchSize: -1,*/
/*sort: a!sortInfo(*/
/*field: "abbreviation",*/
/*ascending: true()*/
/*)*/
/*)*/
),
a!buttonLayout(
primaryButtons: a!buttonWidget(
label: "Submit",
submit: true,
value: cons!LMP_BUTTON_VALUES[5],
saveInto: ri!ButtonValueSBGDemographic
),
secondaryButtons: a!buttonWidget(
label: "Cancel",
style: "DESTRUCTIVE",
submit: true,
value: cons!LMP_BUTTON_VALUES[7],
saveInto:ri!ButtonValueSBGDemographic
)
)

},
showWhen: if(ri!typeValueSelected = 20, true, false)

),
a!boxLayout(
label: "Region-Demographic",
contents: {
a!gridLayout(
label: "",
headerCells: {
a!gridLayoutHeaderCell(
label: "Demographic"
),
a!gridLayoutHeaderCell(
label: "Region"
),
a!gridLayoutHeaderCell(
label: "Active"
),
a!gridLayoutHeaderCell(
label: ""
),
a!gridLayoutHeaderCell(
label: ""
)

},
columnConfigs: {
/*a!gridLayoutColumnConfig(*/
/*width: "ICON"*/
/*),*/
/*a!gridLayoutColumnConfig(),*/
a!gridLayoutColumnConfig(),
a!gridLayoutColumnConfig(),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
)
},
rows: a!forEach(
items: local!RegionDemographics,
expression: a!gridRowLayout(
contents: {

a!textField(
value: index(cons!LMP_REF_VALUES_DEMOGRAPHICS,fv!item.demographicid, null),
saveinto: fv!item.demographicid
),
/*a!textField(*/
/*value: fv!item.sbgdescription,*/
/*saveinto: fv!item.sbgdescription*/
/*),*/
a!dropdownField(
label: "",
placeholderLabel: "--- Select a Value ---",
choiceLabels: {
local!regionList.description
},
choiceValues: {
local!regionList.regionid
},
value:fv!item.regionid,
saveInto:fv!item.regionid,
validations: {}

),
a!checkboxField(
label: "gbe-active",
choiceLabels: {
""
},
choiceValues: {
true()
},
value: if(
or(
isnull(
fv!item.activein
),
not(
fv!item.activein
)
),
null,
toboolean(
fv!item.activein
)
),
saveInto: {
a!save(
fv!item.activein,
if(
isnull(
save!value
),
false(),
save!value
)
)

},
align: "CENTER"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_UP"
),
altText: "Up",
caption: "Move Up ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = 1,
{},
{
a!save(
local!RegionDemographics,
insert(
local!RegionDemographics,
fv!item,
fv!index - 1
)
),
a!save(
local!RegionDemographics,
remove(
local!RegionDemographics,
fv!index + 1
)
)
}
)
}
)
),
size: "ICON"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_DOWN"
),
altText: "Down",
caption: "Move Down ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = count(
local!RegionDemographics
),
{},
{
a!save(
local!RegionDemographics,
insert(
local!RegionDemographics,
fv!item,
fv!index + 2
)
),
a!save(
local!SBGDemographics,
remove(
local!SBGDemographics,
fv!index
)
)
}
)
}
)
),
size: "ICON"
)
}
)
),
addRowLink: a!dynamicLink(
label: "Add Region-Demographic Mapping",
saveInto: a!save(
local!RegionDemographics,
append(
local!RegionDemographics,
'type!{urn:com:appian:types:LMP}LMP_Map_Region_Demographic'(
activein: true()
)
)
)
),
shadeAlternateRows: true
/*paginginfo: a!pagingInfo(*/
/*startIndex: 1,*/
/*batchSize: -1,*/
/*sort: a!sortInfo(*/
/*field: "abbreviation",*/
/*ascending: true()*/
/*)*/
/*)*/
),
a!buttonLayout(
primaryButtons: a!buttonWidget(
label: "Submit",
submit: true,
value: cons!LMP_BUTTON_VALUES[5],
saveInto: ri!ButtonValueRegionDemographic
),
secondaryButtons: a!buttonWidget(
label: "Cancel",
style: "DESTRUCTIVE",
submit: true,
value: cons!LMP_BUTTON_VALUES[7],
saveInto:ri!ButtonValueRegionDemographic
)
)

},
showWhen: if(ri!typeValueSelected = 21, true, false)

),
a!boxLayout(
label: "Function-Demographic",
contents: {
a!gridLayout(
label: "",
headerCells: {
a!gridLayoutHeaderCell(
label: "Demographic"
),
a!gridLayoutHeaderCell(
label: "Function"
),
a!gridLayoutHeaderCell(
label: "Active"
),
a!gridLayoutHeaderCell(
label: ""
),
a!gridLayoutHeaderCell(
label: ""
)

},
columnConfigs: {
/*a!gridLayoutColumnConfig(*/
/*width: "ICON"*/
/*),*/
/*a!gridLayoutColumnConfig(),*/
a!gridLayoutColumnConfig(),
a!gridLayoutColumnConfig(),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
),
a!gridLayoutColumnConfig(
width: "ICON"
)
},
rows: a!forEach(
items: local!FunctionDemographics,
expression: a!gridRowLayout(
contents: {

a!textField(
value: index(cons!LMP_REF_VALUES_DEMOGRAPHICS,fv!item.demographicid, null),
saveinto: fv!item.demographicid
),
/*a!textField(*/
/*value: fv!item.sbgdescription,*/
/*saveinto: fv!item.sbgdescription*/
/*),*/
a!dropdownField(
label: "",
placeholderLabel: "--- Select a Value ---",
choiceLabels: {
local!FunctionList.description
},
choiceValues: {
local!FunctionList.functionid
},
value:fv!item.functionid,
saveInto:fv!item.functionid,
validations: {}

),
a!checkboxField(
label: "gbe-active",
choiceLabels: {
""
},
choiceValues: {
true()
},
value: if(
or(
isnull(
fv!item.activein
),
not(
fv!item.activein
)
),
null,
toboolean(
fv!item.activein
)
),
saveInto: {
a!save(
fv!item.activein,
if(
isnull(
save!value
),
false(),
save!value
)
)

},
align: "CENTER"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_UP"
),
altText: "Up",
caption: "Move Up ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = 1,
{},
{
a!save(
local!FunctionDemographics,
insert(
local!FunctionDemographics,
fv!item,
fv!index - 1
)
),
a!save(
local!FunctionDemographics,
remove(
local!FunctionDemographics,
fv!index + 1
)
)
}
)
}
)
),
size: "ICON"
),
a!imageField(
label: "delete " & fv!index,
images: a!documentImage(
document: a!iconIndicator(
"MOVE_DOWN"
),
altText: "Down",
caption: "Move Down ",
link: a!dynamicLink(
value: fv!index,
saveInto: {
if(
fv!index = count(
local!FunctionDemographics
),
{},
{
a!save(
local!FunctionDemographics,
insert(
local!FunctionDemographics,
fv!item,
fv!index + 2
)
),
a!save(
local!FunctionDemographics,
remove(
local!FunctionDemographics,
fv!index
)
)
}
)
}
)
),
size: "ICON"
)
}
)
),
addRowLink: a!dynamicLink(
label: "Add Function-Demographic Mapping" ,
saveInto: a!save(
local!FunctionDemographics,
append(
local!FunctionDemographics,
'type!{urn:com:appian:types:LMP}LMP_Map_Function_Demographic'(
activein: true()
)
)
)
),
shadeAlternateRows: true

),
a!buttonLayout(
primaryButtons: a!buttonWidget(
label: "Submit",
submit: true,
value: cons!LMP_BUTTON_VALUES[5],
saveInto: ri!ButtonValueFunctionDemographic
),
secondaryButtons: a!buttonWidget(
label: "Cancel",
style: "DESTRUCTIVE",
submit: true,
value: cons!LMP_BUTTON_VALUES[7],
saveInto:ri!ButtonValueFunctionDemographic
)
)

},
showWhen: if(ri!typeValueSelected =22, true, false)

),
}
)
}
)
)

  Discussion posts and replies are publicly visible

Parents
  • Typically you won't write to the DB directly from an interface, but rather save the data when you click on submit.

    If that already covers your case, I would suggest to have your interface as a form in a process model and then save the data with the smart service.

    You have plenty of examples as well on the academy.

    Additionally, it is not recommended to use constants like this:

    LMP_BUTTON_VALUES[5],

    I would rather save the value you have on the fifth item to a new constant, so the code is easier to read.

  • Not every interface is displayed in the context of a running process model (e.g. Record Views), where there may be patterns when updating the database directly from the User Interface will be legitimate. Typically (although there will always be exceptions) you would only make simple updates via this pattern. Anything that is complex can easily lead you to ending up trying to replicate all of the features found in a process model! So beware!

  • Hi All,

    i configured the Process Flow with all the details with Write to Datastore activity, but i get the below error, what am i missing

    An error occurred while trying to write to the entity “LMP_REF_REGION” [id=678cceda-7c25-475b-b4fd-29be176e50e2@20938, type=LMP_REF_REGION (id=5106)] (data store: LMP Nomination Process Data Store). Details: org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): LMPREFREGIONDT4986 Data: TypedValue[it=5106,v={<null>,1,REGN01,APA,1,<null>,,<null>,}]

    Warm Regards

    Vineeth

  • Please try by sending the Id as well along with CDT "LMP_REF_REGION" like "{5106,1,REGN01,APA,1,<null>,,<null>,}"or make it as auto-generated 

  • Hi Vineeth - this is telling you that the row(s) you;re trying to insert into the Database table don't have any values for the Primary Keys. Typically we designate an Integer column in the database as the Primary Key and get the database to automatically generate that key for us so we don't have to worry about it in Appian.

    If you choose to not do this you must provide a value when sending the data from Appian to the DB.

Reply
  • Hi Vineeth - this is telling you that the row(s) you;re trying to insert into the Database table don't have any values for the Primary Keys. Typically we designate an Integer column in the database as the Primary Key and get the database to automatically generate that key for us so we don't have to worry about it in Appian.

    If you choose to not do this you must provide a value when sending the data from Appian to the DB.

Children