Filters

Hi. I want a user to select a a role in a "Roles Requested" dropdown. If that role contains the word "Contractor," roles that don't have the word "Contractor" should not be available for selection. I'm using this filter here:

filter(rule!UAF_Contractor_Test, cons!UAF_ROLES_FL)}, but it isn't working. Here's the code for my rule: find("Contractor", ri!rolesRequestedList)>0

Help is appreciated. Thanks

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Can you clarify a bit - are you talking about just one dropdown, or two?  It seems like you're talking about two, but you only mention one ("Roles Requested").

  • 0
    Certified Lead Developer
    in reply to benjamins0003

    So.. I don't understand what you're actually picturing happening in this dropdown - you only want choices shown that have the word "contractor" in them, or something more complicated?  In particular, I'm finding myself confused by the logic that seems to be going on here:

    If that role contains the word "Contractor," roles that don't have the word "Contractor" should not be available for selection.

    Or are you just saying you only want options with "contractor" shown, and i'm over-thinking it?

  • +1
    Certified Lead Developer
    in reply to benjamins0003

    Assuming you were just after the simple approach - there are various ways to do this.  None necessarily require the filter function and a sub expression function, I'd usually just go with a!forEach.  For example:

    load(
      local!allRoles: {
        "Contractor 1",
        "Second Contractor",
        "Accountant",
        "Lawyer",
        "Third Contractor Option",
        "Evaluator"
      },
      
      local!dropdownChoices: a!forEach(
        local!allRoles,
        if(find("Contractor", fv!item) = 0, {}, fv!item)
      ),
      
      local!selection: null(),
      
      a!dropdownField(
        label: "Contractor Options",
        choiceLabels: local!dropdownChoices,
        choiceValues: local!dropdownChoices,
        placeholderLabel: "--select choice--",
        value: local!selection,
        saveInto: local!selection
      )
    )

  • 0
    Certified Lead Developer
    in reply to swethasri

    Local variable definitions (like a!localVariables() or even the older ones load() and with()) must have exactly one "final" expression evaluation after all local variables are declared.  I can't see the rest of the code in your first screenshot but I can tell that you have an a!dropdownField() call followed by something in an a!forEach() call, which is not valid syntax for a!localVariables() (which is what the pink error message is saying).

  • local variable cant able to find.

    a!localVariables(
    local!allRoles: rule!CrochetDSR_JobOpenings_List(),
    local!dropdownChoices: a!forEach(
    local!allRoles,
    if(find("desiredCandidateProfile", fv!item) = 0, {}, fv!item)
    ),
    local!selection: null(),
    a!dropdownField(
    label: "desiredCandidateProfile",
    choiceLabels: local!allRoles.desiredCandidateProfile,
    choiceValues: local!allRoles.desiredCandidateProfile,
    placeholderLabel: "--select choice--",
    value: local!selection,
    saveInto: local!selection
    ),
    a!forEach(
    items: rule!CrochetDSR_JobOpenings_List(),
    expression: a!cardLayout(
    contents: {
    a!buttonLayout(
    primaryButtons:a!buttonWidget(
    label: "Job Position",
    submit: true,
    style: "NORMAL"
    )

    ),
    a!buttonLayout(
    primaryButtons:a!buttonWidget(
    label: "update",
    submit: true,
    style: "NORMAL",
    value:a!recordActionField(
    links: a!recordActionItem(
    label: fv!item.desiredCandidateProfile,
    action:'recordType!{a2f7d7b0-7a81-4e33-9d81-a9ce3a5f96f5}Job Opening.actions.{75b6ebfe-76df-491f-88a7-0433479dc575}editOpening',
    identifier: fv!item.id,

    ),
    align: "CENTER")

    )

    ),

    a!richTextDisplayField(
    labelPosition: "COLLAPSED",
    value: {


    a!richTextItem(
    text: " "&fv!item.desiredCandidateProfile,
    color: "ACCENT",

    size: "STANDARD",
    style: "STRONG"

    )


    },
    align: "LEFT"
    ),

    a!richTextDisplayField(
    labelPosition: "COLLAPSED",
    value: {
    a!richTextItem(
    text: "No of Position: "&fv!item.jobpositionid,
    size: "SMALL",
    style: "STRONG"
    )
    },
    align: "LEFT"
    ),
    a!richTextDisplayField(
    labelPosition: "COLLAPSED",
    value: {
    a!richTextItem(
    text: "Skills: "&fv!item.skill,
    size: "SMALL",
    style: "STRONG"
    )
    },
    align: "LEFT"
    ),
    a!richTextDisplayField(
    labelPosition: "COLLAPSED",
    value: {
    a!richTextItem(
    text: "Min Level: "&fv!item.minexplevel,
    size: "SMALL",
    style: "STRONG"
    )
    },
    align: "LEFT"
    ),
    a!richTextDisplayField(
    labelPosition: "COLLAPSED",
    value: {
    a!richTextItem(
    text: "Max Level: "&fv!item.maxexplevel,
    size: "SMALL",
    style: "STRONG"
    )
    },
    align: "LEFT"
    ),
    a!richTextDisplayField(
    labelPosition: "COLLAPSED",
    value: {
    a!richTextItem(
    text: "Job Description: "&fv!item.jobdescription,
    size: "SMALL",
    style: "STRONG"
    )
    },
    align: "LEFT"
    ),

    },

    height: "AUTO",
    marginBelow: "STANDARD"
    )
    )
    )

  • 0
    Certified Lead Developer
    in reply to swethasri

    This is what I was attempting to explain above.  In your code here your localVariables() definition is not correct (in the very way I was referring to previously).  I see you've gotten clarification on this in a new thread already.

    FYI, when posting a long code snippet like this, it helps a lot if you use the "Insert --> Insert Code" feature here in order to generate yourself a Code box, which both retains indentation/formatting as well as limiting the vertical bloat of long code to preserve readability within the thread.