Safe link

I am trying to use safelink outside record link getting the error as expected.

error :Interface Definition: Expression evaluation error at function a!gridField: A grid component [label=“null”] has an invalid value for “columns”. A grid column [label=“Module Names”] has encountered an error. Expression evaluation error at function a!safeLink [line 11]: Could not cast from RecordLink to Safe URI. Details: CastInvalidCould not cast from RecordLink to Safe URI. Details: CastInvalid

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer

    Hi, Could you please tell why are you using safe link ? what is the requirement?

  • okay sure Appian Community with the recordlink the functionality is working fine(The parameter openlinkin cannot be use in my case bcoz the version(2.2)) but the modules has to be open in new tab so I am trying to use same code with safelink. I hope my question is clear. Please suggest me if any possible way for this?

  • 0
    Certified Lead Developer
    in reply to JS0001
    The parameter openlinkin cannot be use in my case bcoz the version(2.2)

    Hi,

    What you mean by cannot be use 2.2. Which Appian version you are using? this openlinkin option available from 21.1 version? 

  • 0
    Certified Lead Developer
    in reply to JS0001

    Hi,

    I didn't understand your use case fully, but this is what I am thinking. You can try this solution. It will work for your situation based on the description your provided. 

    a!gridColumn(
            label: cons!CR_APP_LAB_MODULE_OVERVIEW[2],
            value: a!localVariables(
              local!recordUrl: urlforrecord(
                recordType: cons!CR_RECORD_TYPE_CUSTOMER,
                recordIds: ri!crModuelCheckList_cdt.cif_int /*Not sure why you are using this insted of fv!identifier */
                /*fv!identifier*/
              ),
              local!dashboardViewStub: if(
                fv!row.workflowId_int = cons!CR_WORKFLOW_IDS[1],
                cons!CR_MODULES_DASHBOARD_URL_STUBE[1],
                if(
                  fv!row.workflowId_int = cons!CR_WORKFLOW_IDS[2],
                  cons!CR_MODULES_DASHBOARD_URL_STUBE[2],
                  cons!CR_MODULES_DASHBOARD_URL_STUBE[3]
                  /*Note: Add all your remaining if conditions here if any*/
                )
              ),
              local!recordUrlWithSpecificView: substitute(
                local!url,
                "summary",
                local!dashboardViewStub
              ),
              a!richTextDisplayField(
                value: {
                  a!richTextItem(
                    text: fv!row.workflowDesc_txt,
                    link: a!safeLink(
                      label: fv!row.workflowDesc_txt,
                      uri: local!recordUrlWithSpecificView
                    )
                  )
                }
              )
            )
          )

  • okay thanks for your help and Could you please tell the line 20 representing here (i.e. local!url) is that local!recordUrl or need to define local variable  as a seperate var? Bcoz I tried with the code it is throwing error for me

  • 0
    Certified Lead Developer
    in reply to JS0001

    I forgot to update at line no 20. You can try this code

    a!gridColumn(
            label: cons!CR_APP_LAB_MODULE_OVERVIEW[2],
            value: a!localVariables(
              local!recordUrl: urlforrecord(
                recordType: cons!CR_RECORD_TYPE_CUSTOMER,
                recordIds: ri!crModuelCheckList_cdt.cif_int /*Not sure why you are using this insted of fv!identifier */
                /*fv!identifier*/
              ),
              local!dashboardViewStub: if(
                fv!row.workflowId_int = cons!CR_WORKFLOW_IDS[1],
                cons!CR_MODULES_DASHBOARD_URL_STUBE[1],
                if(
                  fv!row.workflowId_int = cons!CR_WORKFLOW_IDS[2],
                  cons!CR_MODULES_DASHBOARD_URL_STUBE[2],
                  cons!CR_MODULES_DASHBOARD_URL_STUBE[3]
                  /*Note: Add all your remaining if conditions here if any*/
                )
              ),
              local!recordUrlWithSpecificView: substitute(
                local!recordUrl,
                "summary",
                local!dashboardViewStub
              ),
              a!richTextDisplayField(
                value: {
                  a!richTextItem(
                    text: fv!row.workflowDesc_txt,
                    link: a!safeLink(
                      label: fv!row.workflowDesc_txt,
                      uri: local!recordUrlWithSpecificView
                    )
                  )
                }
              )
            )
          )

  • yes thank you ,all actions are opening in tempo mode instead of in sites.

  • 0
    Appian Employee
    in reply to JS0001

    The function urlforrecord always returns the URL for tempo, so if you want it to open in a site instead you may need to replace the URL accordingly. Usually you'd have to do something like this:

    concat(
      local!siteUrl,
      mid(
        urlforrecord(
          cons!YOUR_RECORD_TYPE,
          fv!identifier
        ),
        find(
          "/records/item",
          urlforrecord(
            cons!YOUR_RECORD_TYPE,
            fv!identifier
          ),
        ) + 13,
        /* Adding 13 because that's the number */
        /* of characters in /records/item */
        10000
      )
    )

    You just need to make sure that the URL for the site is valid - usually this means you need to include the site name, page name, and "record" before the URL above. Something like this:

    https://<your_appian_site>.appiancloud.com/suite/sites/<site_name>/page/<page_name>/record/<record_link_url>/view/summary

  • yes thank you. how to create a component which generates record link by parameters ?

  • 0
    Certified Lead Developer
    in reply to JS0001

    You should be able to assemble an Expression Rule containing essentially the same code Peter posted above, takes in the record type and the identifier, and returns the relevant site-specific URL for the same record.