Client Id in Hook is undefined

We are using different clients and in some of the documentation we found that the context object in the Hook has the clientID property which you can check, e.g:

var url;
if(context.clientID === ‘MY_DEV_CLIENT_ID’){
url = ‘https://dev.myapp.com’;
} else if (context.clientID === ‘MY_PROD_CLIENT_ID’){
url = ‘https://myapp.com’;
}

But when we try this example, looks like the clientID is undefined. What can be the issue here?

1 Like

Hi @EMM

Try using the Realtime Webtask logs extension and console.log to help figure out what is going on.

John

1 Like

Hi @john.gateley Thanks for the quick response. I try that, debagging the Hook but seems like there is no property client Id in the object. That is way is undefined. Is it possible to get to the client Id in the Pre User Registration hooks?

In hooks, use client.id, not context. client_id

Create a new hook and look at the top, there’s a ton of parameter documentation that will help you out.
After you look, you can delete the new hook you just created.

John

1 Like

Hi @john.gateley,

I’m using Pre User Registration hook, and the client object is not accessible there.
I can only access the client object in the Client Credentials Exchange hook.
Is there any option to get to the client id in the pre user registration hook?

Thanks,

Hi @EMM

I suspect it is not available there. You do have the connection ID (a user signs up for a connection, not an application) and could use that and the management API to figure out which client IDs are available for that connection.

John

2 Likes

Hey there!

As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!