Using match function inside a recordlink

I am trying to open record summary for requests but whatever record I open I'm getting record doesn't exist. I attached my code I can understand something is wrong but couldn't get what I was missing.  The ri! Request relation is of type request relation. Anyone can help?

a!sectionLayout(
  contents: a!forEach(
    items: ri!RequestRelation,
    expression: a!cardLayout(
      contents: {
        a!linkField(
          links: a!recordLink(
            label: "link",
            recordType: 
              a!match(
                value: index(
                  a!queryRecordByIdentifier(
                    recordType: 'recordType! Request',
                    identifier: tointeger(fv!item[requestRelation.field.AppId])
                  ),
                  'recordType! Request.fields.applicationId',
                  {}
                ),
                equals: 212,
                then: 'recordType!ABC',
                equals: 213,
                then: 'recordType!ARC',
                default: null
              ),
            identifier: a!match(
              value: index(
                a!queryRecordByIdentifier(
                  recordType: 'recordType! Request',
                  identifier: tointeger(fv!item[requestRelation.field.AppId])
                ),
                'recordType! Request.fields.applicationId',
                {}
              ),
              equals: 212,
              then: 'recordType! Request.relationships.ABC.fields.requestId',
              equals: 213,
              then: 'recordType! Request.relationships.ARC.fields.requestId',
              default: null
            )
          )
        )
      }
    )
  )
)

  Discussion posts and replies are publicly visible

Parents Reply Children
  • 0
    Certified Lead Developer
    in reply to iswaryan3520
    No application id is not primary key,

    may be assuming AppId and Application Id to be same is incorrect for me! So ignore this. 

    If you are passing the identifier correctly then check the value mappings. there is no rule input or data. Simply mentioning field without any variable mapped is weird. 

                equals: 212,
                  then: 'recordType! Request.relationships.ABC.fields.requestId',
                  equals: 213,
                  then: 'recordType! Request.relationships.ARC.fields.requestId',

    Also, you can minimise entire code by querying in the Request record once and based on output (212 or 213) configure record link for ABC or ARC.  something like 

    a!sectionLayout(
      contents: a!forEach(
        items: ri!RequestRelation,
        expression: a!cardLayout(
          contents: {
            a!linkField(
              links:  a!match(
                    value: index(
                      a!queryRecordByIdentifier(
                        recordType: 'recordType! Request',
                        identifier: tointeger(fv!item[requestRelation.field.AppId])
                      ),
                      'recordType! Request.fields.applicationId',
                      {}
                    ),
                    equals: 212,
                    then: a!recordLink(
                label: "link",
                recordType: 'recordType!ABC',
                identifier: 'recordType! Request.relationships.ABC.fields.requestId'),
                    equals: 213,
                    then: a!recordLink(
                label: "link",
                recordType: 'recordType!ARC',
                identifier:'recordType! Request.relationships.ARC.fields.requestId'),
                    default: a!dynamiclink()
                  )
                 
              )
            
          }
        )
      )
    )

    This cleans the code, you can even use if else instead of match here as there are not many conditions. Check each block ( value, identifier) by passing in test data/ hard coded data to verify each block is functioning as expected depending on input.

  • there is no rule input or data. Simply mentioning field without any variable mapped is weird

    Yes , I'm only getting the Primary key value as rule input from ri! Requestrelation . But with Is there any way to get the request id  for each record