Editable grid

Hi,

We are having a editable grid where the columns are relation, soeid, geid, firstname, lastname.

Relation is a dropdown field with the values {employee, contractor, client}.

Soeid is a user picker field and the remaining columns are text fields.

If user select employee or contractor in the dropdown and he should select soeid then the remaining columns will autopopulate related to the soeid.

If user select client then the soeid and geid get disabled(grayed out) and he needs to fill all the other columns.

My task is here

1. when the user first select employee and enter a soeid then the other columns will populate.

2. if the user select client again in the dropdown the soeid, geid, firstname, lastname which was already populated  should become blank.

How to achieve the above functionality

Thanks in advance.

  Discussion posts and replies are publicly visible

  • rows:{
    a!forEach(
    items:ri!relatedPersons,
    expression:
    a!gridRowLayout(
    contents: {
    rule!relatedPersonIncidentDropdown(
    selectedRole: fv!item.relationship,
    disabled: ri!readOnly= true,
    ),
    a!pickerFieldUsers(
    value: fv!item.soeid,
    a!localVariables(
    local!empData: rule!QE_Employee(soeId: fv!item.soeid).data,
    if(
    a!isNullOrEmpty(fv!item.soeid),
    {
    a!save(fv!item.geid,{}),
    a!save(fv!item.firstName,{}),
    a!save(fv!item.lastName,{}),
    },
    {
    a!save(fv!item.geid, local!empData.geid),
    a!save(
    fv!item.firstName,
    local!empData.firstName
    ),
    a!save(
    fv!item.lastName,
    local!empData.lastName
    ),
    }
    )
    ),
    },
    maxSelection: 1,
    showWhen: not(ri!oreRelated= true),
    readOnly: ri!readOnly= true,
    disabled: and(not(rule!AF_RULE_isBlank(fv!item.relationship)),
    not(contains(cons!GCC_VAL_RELATION,
    fv!item.relationship
    )
    )
    )
    ),
    a!textField(
    value: fv!item.geid,
    saveInto: fv!item.geid,
    showWhen: not(ri!oreRelated = true),
    readOnly: ri!readOnly = true,
    disabled: not(
    rule!AF_RULE_General_isBlank(fv!item.relationship)
    )
    ),
    a!textField(
    value:fv!item.lastName,
    saveInto: fv!item.lastName,
    readOnly: ri!readOnly= true,
    disabled: and(contains(cons!GCC_VAL_RELATION,
    fv!item.relationship
    ),
    not(ri!oreRelated= true)
    )
    ),
    a!richTextDisplayField(
    showWhen: not(ri!readOnly= true),
    value:
    a!richTextIcon(
    icon: "times",
    color: "Negative",
    linkStyle: "STANDALONE",
    link: a!dynamicLink(
    value: null,
    saveInto:{
    a!save(
    ri!relatedPersons,
    value: remove(ri!relatedPersons, fv!index)
    ),})))})
    )

  • 0
    Certified Senior Developer

    Hi 

    Here is the code 

    load(
    local!a:{"employee", "contractor", "client"},
    local!soeid:{"A","B"},
    local!b,
    local!c,
    {
    
    a!gridLayout(
    headerCells: {
    a!gridLayoutHeaderCell(label: "Relation"),
    a!gridLayoutHeaderCell(label: "soeid"),
    a!gridLayoutHeaderCell(label: "geid"),
    a!gridLayoutHeaderCell(label: "firstname"),
    a!gridLayoutHeaderCell(label: "lastname"),
    a!gridLayoutHeaderCell(label: "")
    },
    rows: {
    a!forEach(
    items: ri!relatedPersons,
    expression: a!gridRowLayout(
    contents: {
    a!dropdownField(
    choiceLabels: local!a,
    choiceValues: local!a,
    value: fv!item.relation,
    saveInto: {
    fv!item.relation,
    
    a!save(
    local!b,
    rule!KJA_decision(
    relation:fv!item.relation
    )),
    
    a!save(
    fv!item.soeid,
    if(
    index(local!b,"issoeidRequired",{})=true(),
    fv!item.soeid,
    null
    )),
    
    a!save(
    fv!item.geid,
    if(
    index(local!b,"isgeid",{})=true(),
    fv!item.geid,
    null
    )),
    
    if(
    index(local!b,"issoeidRequired",{})=true(),
    { a!save(
    local!c,
    rule!KJA_decision1(
    relation:fv!item.relation,
    soeid:fv!item.soeid
    ))
    ,
    
    a!save(
    fv!item.firstname,
    local!c.lastname
    ),
    a!save(
    fv!item.lastname,
    local!c.lastname
    ),},
    a!save({fv!item.firstname, fv!item.lastname},null)
    ),
    
    },
    placeholder: "---Select--"
    ),
    a!dropdownField(
    choiceLabels: local!soeid,
    choiceValues: local!soeid,
    value: fv!item.soeid,
    saveInto: {
    fv!item.soeid,
    a!save(
    local!c,
    rule!KJA_decision1(
    relation:fv!item.relation,
    soeid:fv!item.soeid
    )),
    
    a!save(
    fv!item.geid,
    local!c.geid
    ),
    
    a!save(
    fv!item.firstname,
    local!c.firstname
    ), a!save(
    fv!item.lastname,
    local!c.lastname
    ),
    },
    placeholder: "---Select--",
    disabled: not(toboolean(or(index(local!b,"issoeidRequired",{}))=true())),
    ),
    
    a!textField(
    value: fv!item.geid,
    saveInto: fv!item.geid,
    
    readOnly: not(toboolean(or(index(local!b,"isgeid",{}))=true())),
    
    ),
    a!textField(
    value: fv!item.firstname,
    saveInto: fv!item.firstname,
    readOnly: ri!readOnly = true,
    
    ),
    a!textField(
    value: fv!item.lastName,
    saveInto: fv!item.lastName,
    readOnly: ri!readOnly = true,
    
    ),
    a!richTextDisplayField(
    showWhen: not(ri!readOnly = true),
    value: a!richTextIcon(
    icon: "times",
    color: "NEGATIVE",
    linkStyle: "STANDALONE",
    link: a!dynamicLink(
    value: null,
    saveInto: {
    a!save(
    ri!relatedPersons,
    value: remove(ri!relatedPersons, fv!index)
    ),
    
    }
    )
    )
    )
    }
    )
    )
    }
    )}
    )

    temp CDT i created to use in grid 

    The code can be more modified with better performance . I just build to it, to give some idea on how this work can be done 

  • 0
    Certified Lead Developer
    in reply to Komal Jain

    Try this next time, makes the code more readable and easy to copy and paste.