what is the optimal way to trigger an outbound API call from catalog form to validate user input.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 08:04 PM
Integration Use Case:
Before a user submits a catalog form, their input needs to be validated against a third-party database (which is not accessible from the internet). If the validation is successful, the user can proceed with submitting the catalog request. If not, they should correct their input and attempt validation again.
Solution:
1.Trigger an API call to the third-party server for data validation when the user makes changes in the catalog form field. (Trigger API call through on-change client script)
2.Provide a button in the catalog form to trigger the API call for data validation.(Trigger API call through a widget button in catalog form)
3.Validate the data through an API call when the user submits the form using an on-submit catalog client script.
Question: Which method would be preferable solution for a better user experience and platform performance? What would be the optimal approach for this use case? Does it require a MIDServer(Basic Auth) for outbound calls?
- Labels:
-
Architect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 08:47 PM
HI @Anto Alad1 ,
I trust you are doing great.
For a better user experience and platform performance, the optimal approach for this use case would be to use method 1: Trigger an API call to the third-party server for data validation when the user makes changes in the catalog form field. This approach allows for real-time validation as the user fills in the form, providing immediate feedback on any incorrect inputs.
Using an on-change client script to trigger the API call ensures that the validation is performed as the user progresses through the form, reducing the chances of submitting incorrect data. This approach also minimizes the need for the user to go back and correct multiple fields at once.
Method 2, which involves providing a button in the catalog form to trigger the API call, may introduce additional steps and interruptions in the user flow. Users would have to manually click the button to initiate the validation, which can be cumbersome and may lead to delays in form submission.
Method 3, validating the data through an API call when the user submits the form using an on-submit catalog client script, may result in the user having to correct the entire form if there are any validation errors. This can be frustrating for users, especially if the form is lengthy, and may lead to more time-consuming interactions.
Regarding the use of a MID Server (Basic Auth) for outbound calls, it depends on the specific requirements of your integration. If the third-party server requires Basic Authentication for accessing its API, then using a MID Server can be a suitable option. The MID Server acts as a secure gateway between ServiceNow and external systems, allowing you to make authenticated outbound API calls. However, if the third-party server does not require Basic Authentication or if there are alternative authentication methods available, you may not necessarily need a MID Server for this integration.
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2023 09:59 PM
Hi Amit,
Thanks for the response. Forgot to mention, this has to validate multiple fields from catalog form. Considering this will onchange trigger be an viable solution? Also can ServiceNow(Outbound) interact with an onperm Server(no internet) without MIDServer? Also I understand any communication via MIDserver can be through only basic auth. Kindly confirm if my understanding is correct?
Note : Thirdparty DB Server supports oAuth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2023 07:29 PM
onChange should be used for the best UX, even with multiple field, you just need to use g_form.getValue for other fields outside if your validation relates to other fields.
For your concerns of MidServer and basic auth, you're a half of correct. Principally, any server to server can only perform non-interative authentication (and Basic is one of them), since OAth is interactive, you need another tool/methodlogy to perform OAuth first to generate access token. Then store it somewhere in the same host of Mid Server. Then, you need to write a powershell script that can be call call request request to DB Server with your stored token.
Finally, use Orchestra or Flow (with PowerShell step ) to call powershell script.
Another option (after access token is generated and stored). You can write PowerShell script to call RestRequest to ServiceNow to update the header config of your Outbound WS Record, the value of header should be like "Bearer <generated token>". Once this step done, you can use your Outbound WS as normal (no need to set username & password, the header already contaain the authentication info)