Skip to main content
December 9, 2021
Question

How to remove duplicate items

  • December 9, 2021
  • 12 replies
  • 0 views

    How to remove values in this grid?

    12 replies

    stefanhelzle0001
    Brainy
    December 9, 2021

    Do you have a few more details? Where is the data coming from? What do you mean with "remove"? What did you try?

    December 9, 2021

    Hi stefan ,

    this is my code, as per above post , If i am taking any action in any contrct no,  only that should be visible

    Not both as per pic

    a!localVariables(
    local!IMcaseValidation: false(),
    local!selectedContractsData,
    local!invoiceReviewData: cast(
    typeof(
    {
    'type!{urn:com:appian:types}CNAM_invoiceReview'()
    }
    ),
    rule!CNAM_InvoiceReviewData(
    businessPartnerNumber: ri!businessPartnerNumber
    )
    ),
    local!selectedIndexes,
    a!formLayout(
    label: concat(
    "Invoice Review - ",
    ri!businessPartnerName,
    " - BP# ",
    ri!businessPartnerNumber
    ),
    contents: {
    a!gridField(
    labelPosition: "COLLAPSED",
    data: local!invoiceReviewData,
    columns: {
    a!gridColumn(
    label: "Contract #",
    sortField: "CNTRCT_NO",
    value: index(
    fv!row,
    "CNTRCT_NO",
    null
    ),
    align: "END"
    ),
    a!gridColumn(
    label: "SAP Balance",
    sortField: "TOTAL_DUE_AMT",
    value: rule!CNAM_formatAmount(
    value: index(
    fv!row,
    "TOTAL_DUE_AMT",
    null
    )
    ),
    align: "END"
    ),
    a!gridColumn(
    label: "WTS/CDH Invoice Amount",
    sortField: "INVOICE_AMT",
    value: index(
    fv!row,
    "INVOICE_AMT",
    null
    ),
    align: "END"
    ),
    a!gridColumn(
    label: "WTS/CDH Invoice Date",
    sortField: "WTS_INVC_DT",
    value: index(
    fv!row,
    "WTS_INVC_DT",
    null
    ),
    align: "END"
    ),
    a!gridColumn(
    label: "Existing Case Category",
    sortField: "CASE_CATEGORY",
    value: index(
    fv!row,
    "CASE_CATEGORY",
    null
    )
    ),
    a!gridColumn(
    label: "Existing Case #",
    sortField: "CASE_ID",
    value: index(
    fv!row,
    "CASE_ID",
    null
    ),
    align: "END"
    ),
    a!gridColumn(
    label: "Assigned To",
    sortField: "ASSIGNEE_NM",
    value: index(
    fv!row,
    "ASSIGNEE_NM",
    null
    )
    ),
    a!gridColumn(
    label: "Action Taken",
    sortField: "IR_STATUS",
    value: displayvalue(
    index(
    fv!row,
    "IR_STATUS",
    null
    ),
    cons!CNAM_IR_CLASSIFICATION_VALUES,
    cons!CNAM_IR_CLASSIFICATION_LABELS,
    ""
    )
    )
    },
    selectionRequired: true(),
    selectionRequiredMessage: "Please select at-least one contract to classify",
    selectable: true(),
    selectionValue: local!selectedIndexes,
    selectionSaveInto: {
    local!selectedIndexes,
    a!save(
    ri!selectedContracts,
    index(
    local!invoiceReviewData,
    local!selectedIndexes,
    "CNTRCT_NO",
    null
    )
    ),
    a!save(
    local!selectedContractsData,
    index(
    local!invoiceReviewData,
    local!selectedIndexes,
    null
    )
    )
    }
    ),
    rule!CNAM_emptyTextField(),
    if(
    rule!APN_isEmpty(
    ri!selectedContracts
    ),
    {},
    a!radioButtonField(
    labelPosition: "COLLAPSED",
    choiceLabels: {
    cons!CNAM_IR_CLASSIFICATION_LABELS
    },
    choiceValues: {
    cons!CNAM_IR_CLASSIFICATION_VALUES
    },
    required: true(),
    value: ri!actionTaken,
    saveInto: {
    ri!actionTaken,
    a!save(
    local!IMcaseValidation,
    if(
    tostring(
    ri!actionTaken
    ) = cons!CNAM_IR_CLASSIFICATION_VALUES[2],
    contains(
    toboolean(
    rule!CNAM_invoiceReviewValidations(
    invoiceReviewData: local!selectedContractsData
    )
    ),
    false()
    ),
    false()
    )
    )
    }
    )
    ),
    rule!CNAM_emptyTextField(),
    a!columnsLayout(
    columns: {
    a!columnLayout(
    contents: {
    a!pickerFieldUsers(
    label: "Assignee",
    groupFilter: cons!CNAM_ALL_GROUPS_CONSTANT[1],
    value: ri!newAssignee,
    saveInto: ri!newAssignee,
    maxSelections: 1,
    required: true(),
    showWhen: if(
    tostring(
    ri!actionTaken
    ) = cons!CNAM_IR_CLASSIFICATION_VALUES[3],
    false(),
    true()
    )
    )
    }
    ),
    rule!CNAM_emptyColumnLayout(),
    rule!CNAM_emptyColumnLayout()
    }
    )
    },
    validations: a!validationMessage(
    message: "Few contracts selected are not valid for Invoice Mismatch case creation, do you still want to proceed?",
    showWhen: and(
    tostring(
    ri!actionTaken
    ) = cons!CNAM_IR_CLASSIFICATION_VALUES[2],
    toboolean(
    local!IMcaseValidation
    ) = true()
    )
    ),
    buttons: a!buttonLayout(
    primaryButtons: {
    a!buttonWidget(
    label: "Classify Anyway",
    value: cons!CNAM_SUBMIT_BUTTON,
    saveInto: ri!buttonAction,
    submit: true(),
    validate: false(),
    style: "PRIMARY",
    showWhen: toboolean(
    local!IMcaseValidation
    ) = true()
    ),
    a!buttonWidget(
    label: "Classify",
    value: cons!CNAM_SUBMIT_BUTTON,
    saveInto: ri!buttonAction,
    submit: true(),
    validate: true(),
    style: "PRIMARY",
    disabled: toboolean(
    local!IMcaseValidation
    ) = true()
    )
    },
    secondaryButtons: {
    a!buttonWidget(
    label: cons!CNAM_CANCEL_BUTTON,
    value: cons!CNAM_CANCEL_BUTTON,
    saveInto: ri!buttonAction,
    submit: true(),
    validate: false()
    )
    }
    )
    )
    )

    stefanhelzle0001
    Brainy
    December 9, 2021

    It seems like the expression "CNAM_InvoiceReviewData" is the source. Is this a DB query? If yes, modify it to only return unique values. Is this querying a DB view? Modify that to only return unique values.

    tanvirs0003
    Inspiring
    December 9, 2021

    Hi[mention:d0f4237f25f54d53ad9e3fb00c5446c4:e9ed411860ed4f2ba0265705b8793d05] Use union() function from where you are sourcing your data in the grid. Union will remove duplicates.
    use it like this -  union (local!data,local!data)

    December 9, 2021

    Hi Tanvir,

    tried union but its not working

    aartii0003
    December 9, 2021

    Hi,

    I see the data in the grid have different set of values in all rows associated with contract IDs.

    One is the row where the data from contract is there and other seems to be the resultant of some left outer joins which you have done to the tables which might be duplicating the rows .

    Union function will only work if both values in the two arrays are exactly same which in this case is not .

    I am not sure about your use case but you may need to rethink on the JOIN clause which is being used here . See if INNER JOIN is something which would work and would only fetch the common rows from the tables .