how to get the updated values form the cdt in editable grid ?

Certified Associate Developer

I  was working with the editable grid . i want the all the updated values from the editable grid from the cdt ?

  Discussion posts and replies are publicly visible

  • 0
    Certified Associate Developer

    You can use a!queryEntity to fetch records from the CDT mapped entity and have it used in some local! variable to be used to create rows for your editable grid.

  • 0
    Certified Lead Developer

    Can you explain in detail what you want to achieve? Nobody here is keen on trying to guess what you want.

  • 0
    Certified Associate Developer
    in reply to ketanb6910

    i was working with the editable grid and the output in the update column has to be updated according to the action perform on grid but i was not getting the correct output . eg. even i'm deleting values other action's are also running 

  • 0
    Certified Lead Developer
    in reply to ketanb6910

    You say "not getting the correct output". I do not know what you expect. Please describe what you expect, what you do to generate that output, and the result that you see.

  • 0
    Certified Associate Developer
    in reply to Stefan Helzle

    /*Interface to fetch and display the data from MC_referenceData and MC_referenceDataAudit table.
    Users will have access to Amend the Assign Group Name, Description,Updated By and Update in the MC_referenceData table.*/
    a!localVariables(
    local!readOnly: true,
    /*Holds the reference data before being edited by the user*/
    local!oldAssignGroupReferenceData: a!refreshVariable(
    value: cast(
    'type!{urn:uk:aviva:appian:mc}MC_referenceData?list',
    rule!MC_getReferenceData(
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1),
    type: cons!MC_ASSIGN_GROUP_TYPE/*dateFilter: today()*/

    )
    ),
    refreshOnVarChange: local!readOnly
    ),
    /*Holds the updated data after being edited by the user.*/
    local!GroupReferenceData: local!oldAssignGroupReferenceData,
    local!OldGroupName: reject(
    fn!isnull,
    if(
    toboolean(
    local!oldAssignGroupReferenceData.isActive
    ) = true,
    local!oldAssignGroupReferenceData.value,
    null
    )
    ),
    local!newGroupName: reject(
    fn!isnull,
    if(
    toboolean(local!GroupReferenceData.isActive) = true,
    local!GroupReferenceData.value,
    null
    )
    ),
    local!addGroup: false(),
    local!deletedGroup,
    local!comments,
    local!deleteMessage: a!forEach(
    items: local!deletedGroup,
    expression: fv!item.value
    ) & " Group Name is deleted.",
    local!updatedValues: {},
    local!addedNewValues:{

    a!forEach(
    items:local!OldGroupName,
    expression:if(
    where(length(local!OldGroupName)<>length(local!OldGroupName)),
    {},
    local!newGroupName[fv!item]
    )



    )
    },


    a!boxLayout(
    label: "Manage Group",
    contents: {
    /*Section for displaying the Group name which can be edited by the user.*/
    a!sectionLayout(
    /*label: "Following are the Group name.",*/
    labelColor: "#008080",
    contents: {
    a!gridLayout(
    headerCells: {
    a!gridLayoutHeaderCell(label: "Group Id", align: "CENTER"),
    a!gridLayoutHeaderCell(label: "Group Name", align: "CENTER"),
    a!gridLayoutHeaderCell(label: "Is Active", align: "CENTER"),
    a!gridLayoutHeaderCell(label: "Updated By", align: "CENTER"),
    a!gridLayoutHeaderCell(label: "Updated On", align: "CENTER"),
    a!gridLayoutHeaderCell(label: "End Date", align: "CENTER"),
    a!gridLayoutHeaderCell(label: "")
    },
    columnConfigs: {
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 1),
    a!gridLayoutColumnConfig(width: "ICON")
    },
    rows: a!forEach(
    items: local!GroupReferenceData,
    expression: if(
    fv!item.isActive,
    a!gridRowLayout(
    id: fv!index,
    contents: {
    a!textField(
    label: " Group Id",
    value: fv!item.refCode,
    saveInto: fv!item.refCode,
    required: false(),
    readOnly: local!readOnly,
    align: "CENTER"
    ),
    a!textField(
    label: "Group Name",
    value: fv!item.value,
    saveInto: fv!item.value,
    required: true,
    readOnly: local!readOnly,
    align: "CENTER"
    ),
    a!checkboxField(
    label: "Is Active",
    choiceLabels: { "" },
    choiceValues: { true },
    value: fv!item.isActive,
    saveInto: fv!item.isActive,
    disabled: local!readOnly,
    align: "CENTER"
    ),
    a!textField(
    label: "Updated By",
    value: fv!item.updatedBy,
    saveInto: fv!item.updatedBy,
    readOnly: true(),
    align: "CENTER"
    ),
    a!textField(
    label: "Updated On",
    value: fv!item.updatedOn,
    saveInto: fv!item.updatedOn,
    readOnly: true(),
    align: "CENTER"
    ),
    a!dateField(
    label: "End Date",
    value: fv!item.endDate,
    saveInto: fv!item.endDate,
    readOnly: local!readOnly,
    align: "CENTER"
    ),
    a!richTextDisplayField(
    value: a!richTextIcon(
    icon: "close",
    altText: "delete " & fv!index,
    caption: "Remove row",
    link: a!dynamicLink(
    value: fv!index,
    saveInto: {
    a!save(fv!item.isActive, false),
    a!save(
    local!deletedGroup,
    append(local!deletedGroup, fv!item)
    ),
    a!save(
    local!GroupReferenceData,
    remove(local!GroupReferenceData, save!value)
    ),
    a!save(local!addGroup, false),
    a!save(local!oldAssignGroupReferenceData,remove(local!oldAssignGroupReferenceData,save!value))
    }
    ),
    linkStyle: "STANDALONE",
    showWhen: local!readOnly = false,
    color: "NEGATIVE"
    )
    )
    }
    ),
    {}
    )
    ),
    addRowLink: a!dynamicLink(
    label: "Add Group",
    saveInto: {
    a!save(local!addGroup, true),
    a!save(
    local!GroupReferenceData,
    append(
    local!GroupReferenceData,
    'type!{urn:uk:aviva:appian:mc}MC_referenceData'(
    refCode: null,
    value: null,
    description: null,
    type: cons!MC_ASSIGN_GROUP_TYPE,
    isActive: true(),
    startDate: today(),
    endDate: today(),
    createdOn: now(),
    createdBy: loggedInUser(),
    updatedOn: now(),
    updatedBy: loggedInUser()
    )
    )
    )
    },
    showWhen: local!readOnly = false
    )
    ),
    a!paragraphField(
    label: "Comments",
    value: local!comments,
    saveInto: local!comments,
    characterLimit: 300,
    showWhen: local!readOnly = false,
    required: true
    )
    }
    ),
    a!buttonArrayLayout(
    buttons: {
    a!buttonWidget(
    label: cons!MC_BUTTON_EDIT,
    saveInto: { a!save(local!readOnly, false),a!save(local!addGroup,false) },
    style: "SECONDARY",
    showWhen: local!readOnly = true
    ),
    a!buttonWidget(
    label: cons!SHARED_BUTTON_CANCEL,
    saveInto: {
    a!save(local!readOnly, true),
    a!save(local!deletedGroup, null),
    a!save(local!newGroupName, local!OldGroupName),
    a!save(
    local!GroupReferenceData,
    local!oldAssignGroupReferenceData
    ),
    a!save(local!addGroup, false)
    },
    style: "NORMAL",
    showWhen: local!readOnly = false
    ),
    a!buttonWidget(
    label: "Update Group",
    saveInto: {
    a!writeToMultipleDataStoreEntities(
    valuesToStore: {
    a!entityData(
    entity: cons!MC_DSE_REFERENCE_DATA,
    data: {
    local!GroupReferenceData,
    a!forEach(
    items: local!deletedGroup,
    expression: 'type!{urn:uk:aviva:appian:mc}MC_referenceData'(
    refId: fv!item.refId,
    refCode: fv!item.refCode,
    value: fv!item.value,
    description: fv!item.description,
    type: fv!item.type,
    startDate: fv!item.startDate,
    endDate: fv!item.endDate,
    isActive: fv!item.isActive,
    createdOn: fv!item.createdOn,
    createdBy: fv!item.createdBy,
    updatedOn: now(),
    updatedBy: loggedInUser()
    )
    )
    }
    ),
    a!entityData(
    entity: cons!MC_DSE_REFERENCE_DATA_AUDIT,
    data: 'type!{urn:uk:aviva:appian:mc}MC_referenceDataAudit'(
    refCode: cons!MC_INSURER_NAME_REF_CODE,
    update: {
    if(
    and(rule!APN_isEmpty(local!OldGroupName),where(local!OldGroupName<>local!newGroupName)),
    {},
    "New Group Added: "& local!addedNewValues
    ),


    if(and(rule!APN_isEmpty(local!deletedGroup)),{}," Deleted Message: "&local!deleteMessage)
    },
    description: (local!comments),
    updatedBy: loggedInUser(),
    updatedOn: now(),
    type: cons!MC_ASSIGN_GROUP_TYPE
    )
    )
    },
    onSuccess: "Group name updated successfully."
    ),
    a!save(local!readOnly, true),
    a!save(local!comments, null),
    a!save(local!deletedGroup, null)
    },
    style: "PRIMARY",
    showWhen: local!readOnly = false,
    validate: true
    )
    },
    align: "END"
    ),
    a!sectionLayout(
    label: "Audit Details",
    labelColor: "#008080",
    contents: {
    a!gridField(
    data: rule!MC_getReferenceDataAudit(
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: - 1),
    refCode: cons!MC_INSURER_NAME_REF_CODE,
    type: cons!MC_ASSIGN_GROUP_TYPE
    ),
    columns: {
    a!gridColumn(
    label: "#Id",
    sortField: "id",
    value: fv!row.id,
    align: "CENTER"
    ),
    a!gridColumn(
    label: "Updates",
    sortField: "update",
    value: fv!row.update,
    align: "CENTER"
    ),
    a!gridColumn(
    label: "User Comment",
    sortField: "description",
    value: fv!row.description,
    align: "CENTER"
    ),
    a!gridColumn(
    label: "Updated By",
    sortField: "updatedBy",
    value: fv!row.updatedBy,
    align: "CENTER"
    ),
    a!gridColumn(
    label: "Updated On",
    sortField: "updatedOn",
    value: fv!row.updatedon,
    align: "CENTER"
    )
    },
    pageSize: 5,
    initialSorts: a!sortInfo(field: "updatedOn", ascending: false),
    spacing: "DENSE",
    rowHeader: 1,
    refreshOnVarChange: local!readOnly
    )
    },
    isCollapsible: true,
    isInitiallyCollapsed: false,
    marginBelow: "STANDARD"
    )
    },
    style: "#008080",
    shape: "ROUNDED"
    )
    )

    in the audit details log update column for the adding operation it should show only new added value but it's showing all the values which are there in the llocal!newGroupNmae Variables

  • 0
    Certified Lead Developer
    in reply to ketanb6910

    This line:

    and(rule!APN_isEmpty(local!OldGroupName),where(local!OldGroupName<>local!newGroupName)),

    looks suspicious. What logic do you want to express?

    Please modify your post and use this.

  • 0
    Certified Associate Developer
    in reply to Stefan Helzle

    HI Stefan the requirement is there is a editable grid and i can perform the add , update and delete operations .and the operation log i'm storing in the cdt . The problem is when i'm performing the add operation in the audit details log update column all the values are that are showing

  • 0
    Certified Lead Developer
    in reply to ketanb6910

    I understand, but that is not an answer to my question.

    My problem here is, that you post a large and complex user interface and expect that I spend my time on trying to understand what this is doing, without the option to somehow run or debug it.

    So ... when your problem is triggered at the moment you push some button, then try to understand what the logic inside that button is doing.

    I can help you with this, but do not expect from me that I spend a hours time on trying to understand your code!

    stackoverflow.com/.../how-to-ask

  • 0
    Certified Associate Developer
    in reply to Stefan Helzle

    no worries i can take it as a positive feedback