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
  • 0
    Certified Lead Developer

    Few questions:

    Is 'applicationId' the primary key in Request record? 

    in the value attribute, possible values are  'recordType! Request.relationships.ABC.fields.requestId', 'recordType! Request.relationships.ARC.fields.requestId', and null. Here, you are not passing any data from rule input or variable instead directly request Id field is mentioned from the record. This seems fishy! 

  • No application id is not primary key, I'm getting the ri! requestrelation from record picker value where the request id getting selected , so based on that id I'm trying to open the particular record summary. So using the queryrecordidentifier I'm trying to get application id

  • 0
    Certified Lead Developer
    in reply to iswaryan3520

    Here, the identifier should have the primary id value for record data  to return details for. You are passing AppId from requestRelation as identifier to Request record. If AppId doesnt hold primary id value for Request record your output will not be appropriate. So start with passing it correct field/value to query Request record with

     

     a!queryRecordByIdentifier(
                        recordType: 'recordType! Request',
                        identifier: tointeger(fv!item[requestRelation.field.AppId])
                      ),
     

  • The value I'm passing to the identifier is primary key of Request record only

  • 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 

Reply Children
No Data