Regex and Form Fields

I am in Salesforce Lightning. I need to have several pieces of data to populate after creating a new case. I use a number of form fields to allow the user to answer basic questions, of which, the answers end up being pasted into the Case Description field. However, I also need to pull in data from several fields, but those fields are only visible after the case is created. I have tries using 1 snippet to create the case, then importing another snippet that grabs the info I need via Regex. The problem is, the Regex is returning errors because when I run the first snippet, it is also trying to fill in fields from the imported snippet, even though the imported snippet command is the very last command listed. A way to have the regex portion of the snippet to run after the form fields are entered and the next page loads....that would be amazing. Any ideas for a solution?

When inserting a snippet, the contents of {site} commands are evaluated at the start of the insertion.

So even if the contents of the page changes over the course of the insertion, any {site} commands will reflect the contents of the page when that insertion started.

So what you're asking for sounds like it is would be impossible to do in a single snippet. You'll need to have one snippet that creates the case, and a second snippet that reads the new contents after the case was created.

Hope this helps!

1 Like

That is exactly what I implemented! Ended up inserting a note with a brief direction to the user.

When this case finishes being created, it will automatically open in edit mode.
At that point, type *9 on your keypad.

When the user presses *9, that snippet grabs the required info via Regex, moves down the existing Case Description info, and pastes in the Regex results. Boom! Check it out in action:

Snippet Example

That's pretty neat! :slight_smile:

I wonder why at timestamp 00:10s, you type in the date, instead of using a {formdate} command? :thinking: Perhaps there is some improvement we can make to the command?

1 Like

I have since updated that to insert the calendar date field.

{formdate: MM/DD/YYYY; name=lda; default=}

We have to manually enter/select the date because it is a data point that we have to obtain from another website....our Learning Management System.

1 Like