Recent searches


No recent searches

Issue with API Fields updating instantly within Nav Bar App



Posted Jul 13, 2022

I'm using client.request() to update a Users Suspension status however it does not update until the iframe is exited or the page is completely refreshed. Is there a solution to updating this instantly so it can reflect within the app?

Here is my current code:

function suspendUser(userID){
    const options = {
  url: '/api/v2/users/'+ userID,
  type: 'PUT',
  data: JSON.stringify({
    user: {
      suspended: true
    }
  }),
  contentType: 'application/json'
};

client.request(options).then(
  (res) => {
    console.log(`Suspended user ${res.user.id}`);
    client.invoke('notify',`Suspended user ${res.user.name}`, 'notice');
    reloadUsers();
  },
  (res) => {
    console.log(`Error ${res.status}`);
    client.invoke('notify',`Error ${res.status}`, 'notice')
  }
);
}


0

6

6 comments

image avatar

Eric Nelson

Zendesk Developer Advocacy

Hey Gaby,

Are you saying that the user suspension event doesn't happen until the app refreshes or just the UI?

Thanks! 

0


Eric Nelson Yes, the user suspension event doesn't happen until the app refreshes. Even if I use location.reload(); it doesn't work until the page refreshes completely. 

0


image avatar

Eric Nelson

Zendesk Developer Advocacy

Hey Gaby,

What do you have kicking off that function? I haven't been able to replicate your issue. Here is a small example application that is functioning as expected. Hopefully this can point you in the right direction.

Thanks,

Eric

0


Eric Nelson I tried using this and I am still getting the same issue. As I do get a success popup notification saying the user was suspended, it doesn't update the API instantly, it updates after the app is refreshed.

0


image avatar

Eric Nelson

Zendesk Developer Advocacy

That's quite odd, mind if I move this into a ticket so I can assume into your account and take a look? 

0


Eric Nelson I don't need to suspend users anymore and tried it with updating the User's custom roles and that updates instantly. There must be something with the Suspension field that delays in updating but luckily I don't need that right now. Thank you so much for your help again!

0


Please sign in to leave a comment.

Didn't find what you're looking for?

New post