cancel
Showing results for 
Search instead for 
Did you mean: 

How to write a code in WebSDK for the event onBeforeSubmit

Vrishabh
Explorer
0 Kudos
302

Hi Experts,

We have a requirement.

We need to fetch profile.country value on onBeforeSubmit event in the screenset using accounts.search JS API. To do so, we were planning to pass the accounts.search function in Screenset Javascript code. To authenticate the API, we need to pass the querySignature and for that we are generating it with apiKey and signature using HMAC-SHA-1.
For security reason we wanted to place the querySignature generator code in WebSDK and pull the value to pass it as a parameter in accounts.search API.

Could you please let us know how to format the code in WebSDK for onBeforeSubmit event and pass the querySignature to screenset.

Regards,
Vrishabh.

kobico
Advisor
Advisor

Hi Vrishabh

Calling accounts.search directly from the browser is greatly discouraged and can cause a wide range of issues. from data privacy and security to performance and scalability.

Can you please elaborate on your use case and what exactly you're trying to achieve?

Vrishabh
Explorer
0 Kudos

Hi kobico,
Let me give a gist of the scenario we are trying to achieve.
We have a requirement to redirect the user to Registration completion screen after login --if-- the user belongs to Some country value lets say UK.
For the same requirement, we were trying to run an accounts.search API within the onBeforeSubmit event to fetch the country value and add a validation to redirect the user to Registration completion screen.

If you have any alternative way, please suggest us.
Thanks and Regards,
Vrishabh.

KunalBansal
Active Contributor
0 Kudos

Hello awativrishabh,

As per my experience, you need to check the residency of a consumer using some middle API-M solution and then redirect the calls accordingly.

I hope this information was helpful in closing this thread.

Thanks and Regards,

Kunal Bansal

SAP CX Architect

https://www.linkedin.com/in/thekunalbansal

Accepted Solutions (1)

Accepted Solutions (1)

romaingorrias
Advisor
Advisor
0 Kudos

Based on the use case you describe in the comments, I don't believe using onBeforeSubmit is the right way to go. If you want to redirect the user somewhere after login, then I'd suggest you add an onLogin event handler;

see: accounts.addEventHandlers JS

The users being logged in, you'll have access to the profile info through accounts.getAccountInfo JS rather than having to resort to using the search API.

If part of the use case is to prevent the user login if they're not from a specific country, then I would suggest using server side extensions with the onBeforeAccountsLogin and onBeforeSocialLogin events. More info here: Extensions

Answers (0)