Hello,
I am currently working on an application for training purposes. I have a process for adding a record and editing it. I had a sub-process for both, where I am sending an email to a user group whenever a record has been added or edited. I was able to make parts of the email dynamic (e.g. "Information about [dynamicName] has been [changed/added]), but I would like to embed a record summary view link in that email, so that users can navigate straight to the updated record from that email. Now, the urlforrecord() function generates a working URL, but it links to Tempo, and not the summary view of my record. I have been trying a few things, but nothing seems to work. I would be very much obliged if someone helps me figure this out. To sum up: I need to dynamically generate a URL to a record summary view on my site to embed it within the email body.
Thanks!
Discussion posts and replies are publicly visible
Your could try something like this,
substitute( text:urlforrecord( recordType: cons!RECORD_TYPE, recordIds:ri!recordId ), find: "https://YOUR_APPIAN_SITE/suite/tempo/records/item/", replace_with:"https://YOUR_APPIAN_SITE/suite/sites/YOUR_SITE/page/YOUR_PAGE/record/" )
This uses the substitute() function to replace the tempo portion of the URL with your sites record URL.
Thank you! I will definitely try it out!
Has this worked for others? I'm currently trying to utilize this same function:
But am coming up with the following error:
For manually constructing a site-context Record URL, I always suggest encapsulating the functionality in its own expression rule for added flexibility (and, of course, for ease of testing) - this is the one I've used in the past.
a!localVariables( local!defaultURL: urlforrecord(ri!recordType, ri!recordId), local!addSiteContext: if( isnull(ri!siteContext), local!defaultURL, if( isnull(ri!recordId), /* Can't link to a record list in sites context */ local!defaultURL, substitute( local!defaultURL, "tempo/records/item", "sites/" & ri!siteContext & if( isnull(ri!sitePageContext), "", "/page/" & ri!sitePageContext ) & "/record" ) ) ), local!addDashboardContext: if( isnull(ri!dashboardStub), local!addSiteContext, substitute(local!addSiteContext, "summary", ri!dashboardStub) ), local!addDashboardContext ) /* by: Mike Schmitt */
Also: the main issue in your code above seems to merely be an issue of passing keywords into the "substitute()" function, which does not take keywords. I think what you have here might work otherwise if you remove them.
Thanks Mike Schmitt can you point to the keywords I might need to remove? When looking at the description for both the substitute() and urlforrecord() functions, I'm only including the fields that it lists.
The issue here is that "substitute()" itself does not support keyword syntax.
Stupidly, that means you actually can't use parameters when calling the rule (in your case, "text", "find", and "replace"). These are not very well documented and not explained by Appian, it's just something you need to know to look out for in the case of certain primitive rules.
That was it! Removing the field names (keywords) and just separating each element by commas seems to have resolved the issue. Thanks so much!
Mike's answer definitely works, but luckily we're also introducing a new function in 24.1 that will achieve this even easier! Be on the lookout for the upcoming function a!urlForRecord() in the announcement webinar next week