Workaround: openURL in Blueprints - An alternate approach

Workaround: openURL in Blueprints - An alternate approach

There is a roundabout way to open a URL in blueprints after a save event.

By using the 'onBeforeMandatoryFormSave' in Client Script, you can open an external URL.

Now, the problem is, this is designed to be run BEFORE the blueprint is saved, not after, meaning if the user hasn't entered all the data in the blueprint transition, we need to prevent the url from opening. How do we do that?

  1. // to check if 1 value has data
  2. if (form.Length && form.Length !== '')
  3. {
  4.     $Client.openURL("https://www.google.com");
  5. }

  6. // to check if multiple values have data
  7. let l_fields = ["field_1", "field_2", "field_3"];
  8. let openURL = l_fields.every(field => form[field] != null && form[field] !== '');
  9. if (openURL == true)
  10. {
  11.     $Client.openURL("https://www.google.com");
  12. }

The blueprint transition window, the Form, is passed to the client script along with all the values contained within. We can check if the for has everything completed using one of the methods in the code above.

Method 1 will check 1 field for a valid entry. We just need to specify the API name of the field to check. If the field has a value in it, the url will open.

Method 2 checks all fields in a list. If all fields have valid values (i.e != null && != '') then the openURL will return true, otherwise it will return false.
If openURL equates to true, we open the url, otherwise we do nothing.

No, this will still fire before the transition window save event. So it's not a perfect solution, and the logic you use in the client script will need to match the logic requirements of the Blueprint to avoid unintentional opening of the external URL.

However, a bonus to using this is you can pack in extra data validation if you wish for the entered data... that's what this client script event was intended for... we can not only check if a value is empty or not, we can check that it's got the correct data, open the URL and allow the blueprint transition save.