hi there! So, I'm pretty new using Descope (buildi...
# ask-a-descoper
s
hi there! So, I'm pretty new using Descope (building my first app with it) and I have a question I couldn't find an answer yet: on my Descope User's I added 3 Custom Attributes related to their licenses, I'm wondering how can I update those values? I'm assuming I would need to hit an API that would make use of the Descope SDK, but I couldnt figured it out yet.
b
Hi. Assuming you want to update the user from your backend - you can use the management SDK.
s
is there a way to update the customAttributes from my NextJS app?
b
Here's the link to the update user command: https://docs.descope.com/manage/users/
πŸ™Œ 1
a
You can also find all management functions here: https://github.com/descope/node-sdk#management-functions
πŸ™Œ 1
s
so, I was checking the docs and I was able to update it. However I'm wondering if there's any better approach to update more than one customAttribute at once? I found the following ways:
I would like to do something like
await await descopeClient.management._user_._update_(loginId, {attributeIwishToUpdate1: val1, attributeIwishToUpdate2: val2}
instead of having to rewrite
phone displayName roles ...
and so goes on until reach the customAttributes
and also I would rather make just one call than having to do 2+ calling
descopeClient.management.user.updateCustomAttribute
s
Did you look at the
.user.update
function ? With that call, you can update all the properties at once
s
yep, but there's one issue with that one
Copy code
const user = await descopeClient.management.user.load('<mailto:leo@descope.com|leo@descope.com>');
const updt = await descopeClient.management.user.update(user.loginIds[0], user.email, user.phone, user.displayName, user.roleNames, user.tenants, {param1: 'PRO', param2: 1689018774081, param3: 'xxxxxx'})
I need to: 1st load user info 2nd send all the parameters to the funciton in order to not rewrite it to 'undefined' make sense?
it is possible in both ways, but I would rather make 3 calls using promise.All() than loading an unnecessary resource
a
Yes, we understand the pain here, we will take it internally and see how we can expose β€œpatch” option for that. @some-librarian-64280 FYI
πŸ™Œ 1
s
Thanks I just wanted to leave a feedback as a first user, hope it's helpful!
πŸ™ 2