Skip to main content
April 20, 2023
Question

Remove function unable to delete data from the table in database

  • April 20, 2023
  • 5 replies
  • 0 views

a!forEach(
items: local!milestonedata,
expression: {
a!gridRowLayout(
id: fv!index,
contents: {
a!paragraphField(
value: { fv!item.milestone },
saveInto: fv!item.milestone,
characterLimit: 1000,
required: true
),
a!dateField(
value: { fv!item.milestoneDate },
saveInto: {
fv!item.milestonedate,
a!save(fv!item.projectId, local!data.projectId),
a!save(fv!item.phaseId, local!data.phaseId),
a!save(fv!item.isActive, true),
if(
isnull(fv!item.projectMilestoneId),
a!save(fv!item.createdOn, now()),
a!save(fv!item.updatedOn, now())
),
if(
isnull(fv!item.projectMilestoneId),
a!save(fv!item.createdBy, loggedInUser()),
a!save(fv!item.updatedBy, loggedInUser())
)
},
required: true
),
a!dropdownField(
label: "",
labelPosition: "ABOVE",
placeholder: "--- Select a Value ---",
choiceLabels: rule!PLT_GetReferenceDataStatus(parentId: cons!PLT_ParentId[6]).Name,
choiceValues: rule!PLT_GetReferenceDataStatus(parentId: cons!PLT_ParentId[6]).referenceId,
value: fv!item.statusId,
saveInto: fv!item.statusId,
searchDisplay: "AUTO",
required: true,
validations: {}
),
a!richTextDisplayField(
value: a!richTextIcon(
icon: "close",
altText: "delete " & fv!index,
caption: "Remove ",
link: a!dynamicLink(
value: { fv!index, },
saveInto: {
a!save(
local!milestonedata,
remove(local!milestonedata, save!value)
)
}
),
linkStyle: "STANDALONE",
color: "NEGATIVE"
)
)
}
)
}
)
},
selectionSaveInto: {},
height: "SHORT",
addRowlink: a!dynamicLink(
label: "Add Milestone",
value: {
'type!{urn:com:appian:types:PLT}PLT_ProjectMilestones'()
},
saveInto: {
a!save(
local!milestonedata,
append(local!milestonedata, save!value)
)
}
),
rowHeader: 1
)
},
style: "STANDARD",
shape: "SEMI_ROUNDED",
marginAbove: "NONE",
marginBelow: "STANDARD",
showBorder: false,
showShadow: true
),

button code

 a!buttonArrayLayout(
                buttons: {
                  a!buttonWidget(
                    label: "Update",
                    value: true,
                    saveInto: {
                      /*a!save(ri!submit, true),*/
                      /*a!save(ri!plt_projects, local!data),*/
                      /*a!save(ri!milestone, local!milestonedata),*/
                      /*a!save(ri!users, local!users),*/
                      a!save(local!SuccessfulSave, true),
                      a!startProcess(
                        processModel: cons!PLT_PM_UPDATE_PROJECT,
                        processParameters: {
                          milestone: local!milestonedata,
                          plt_projects: local!data,
                          projectid: index(local!data, "projectId", {}),
                          submit: true(),
                          users: local!users
                        }
                      )
                    },
                    submit: true,
                    style: "NORMAL",
                    validate: true,
                    validationGroup: "submit"
                  )
                },
                align: "END"
              )

I am trying to use remove function but its only removing the data from the index but not from the database table when i click on the submit it should be able to remove that data from the table

    5 replies

    April 20, 2023

    stefanhelzle0001
    Brainy
    April 20, 2023

    The remove() function does not do anything to the database. To delete records, use a!deleteRecords or the respective node in a process.

    harshitb6843
    April 20, 2023

    I did not go through your code but the remove function doesn't remove data from the table. I hope you know that. 

    April 20, 2023

    Why do you think it would delete the record from database table?  You just removed the data from the index, you will be needing the identifier of that record and use delete from DSE smart service for permanently deleting the record. But the best practice here is to soft delete the entry by marking a field "isActive" as false for that record

    April 20, 2023

    thank a lot