How do you ENABLE a new user via EFx

Just giving you :poop:

So
 does that mean only UpdateExt works and not Update for this? (I used update for creating the user.)

When in Rome.

But here is the code version then

No I used Update in the widgets and in my straight code

Huh. Well I must have something else random wrong, or it just doesn’t like me passing the new dataset straight into the update.

Anyway, it’s possible and simple enough, so thank you all.

Can confirm that it works with reset too

this.CallService<Ice.Contracts.UserFileSvcContract>(uf => {
    var dsUf = uf.GetByID(iUserName);
    
    if(iEnabled)
    {
      dsUf.UserFile[0].ClearPassword = true;
      dsUf.UserFile[0].PasswordBlank = true;
      dsUf.UserFile[0].PwdExpiresDays = 0;
      dsUf.UserFile[0].PwdExpires = DateTime.Today;
      dsUf.UserFile[0].PwdGrace = 3;
    }
    
    dsUf.UserFile[0].UserDisabled = !iEnabled;
    dsUf.UserFile[0].RowMod = "U";
    uf.Update(ref dsUf);
});
1 Like

Security Man says


Paul F Thompkins No GIF

@Mark_Wonsil better?
image

Should have listened to this earlier, I guess.

image

I’m still not getting any version of UPDATE to work

  • Not in a widget Function
  • Not in a code Function
  • Not in Swagger

BUT
 UpdateExt does work in Swagger, I think because it has that continueProcessingOnError option (that I set to true).
I assume that allows it to move on and finish the job.

I mean, if I have to manually enable the users, I guess that’s not the end of the world. But it’s so close!

I wonder if it’s version specific. If you used my code as is it should work if not then there is something different between 2021.2 and 2022.2 in regards to the UserFile BO. It’s possible you might need to use Erp vs Ice in that version since user lives in both halves, sort of.

Are you first doing the RowMod = “A” to make sure the record exists and THEN enabling with the RowMod = “U” - much like the process in the UI?

Good point, I have been wondering about that, but have not tried anything but Ice.

True, I might give this a whirl in 2022.2.

I mean, no
 I don’t see that in the trace anywhere.

Also, I may be confused – you’re talking about just the enable-user process? Not creating a user, right?

First create the user with all the things. Add it. With that dataset, set disable = false and then update.

Looking at the error above, there is no SysRowID and you won’t get that until you add the record first.

That was my original flow, but it only works to create the new user, never successful to enable.

I’ll call it for today. About time to check for missing shingles. It’s not bad here.

@josecgomez Hope you are staying safe, too. I’m guessing so since you replied earlier.

And for anyone here in the Southeast US.

1 Like

All good thanks @JasonMcD

2 Likes

So i am creating a new user in a function before this. then calling the enable one once the account it added. I have the stuff setup exactly as you have it written @jgiese.wci and I’m on 2022.2.16. But when i run the enable user code it tells me this error

I have a feeling the dataset is empty. but not sure. Are you available to help with this?

{
“HttpStatus”: 500,
“ReasonPhrase”: “REST API Exception”,
“ErrorMessage”: “Object reference not set to an instance of an object.”,
“ErrorType”: “System.NullReferenceException”,
“CorrelationId”: “20121c0f-2ec5-41d5-b52f-8e94e4dc5f98”
}

What is your full code base on this? My guess is you might need another GetByID call added in there after saving the new user vs using the existing dataset.

1 Like

What you have typed i have in a 2nd widget function and i have the create user in another one using widgets. The screen shot below shows how i am creating it. Then i use your method to get the userid and enable it.

this.CallService<Ice.Contracts.UserFileSvcContract>(uf =>{
  var dsUf = uf.GetByID("Rick.Draeger");
  dsUf.UserFile[0].UserDisabled = !dsUf.UserFile[0].UserDisabled; //Toggle User
  dsUf.UserFile[0].RowMod = "U";
  uf.Update(ref dsUf);
  }) ;

Another reason I hate widgets I can’t read the full story it’s like reading a book like this


Sorry going to be touch and go trying to debug it as widgets via the forum. If there are in different function calls and you are getting the data each time it should work fine.

I would advise against using the Alpha POC code I posted that will toggle the user on and off. If this is part of a creation script code it more on these lines

this.CallService<Ice.Contracts.UserFileSvcContract>(uf => {
    var dsUf = uf.GetByID(iUserName);
    
    dsUf.UserFile[0].ClearPassword = true;
    dsUf.UserFile[0].PasswordBlank = false;
    dsUf.UserFile[0].PasswordEmail = "someuser@somesite.edu";
    dsUf.UserFile[0].PwdExpiresDays = 0;
    dsUf.UserFile[0].PwdExpires = DateTime.Today;
    dsUf.UserFile[0].PwdGrace = 3;

    dsUf.UserFile[0].UserDisabled = false;
    dsUf.UserFile[0].RowMod = "U";
    uf.Update(ref dsUf);
});
3 Likes

oh okay looks like im still not getting any data when running this function specifically in postman.