How do you ENABLE a new user via EFx

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.

I respect and cede that idea.

I smell an Idea brewing…

So, with BAQs, we can code with widgets but then see the SQL text that is generated.

Would be nice to have the same with EFx/BPMs.

I know, there’s some obscure place on the server to find it, but if it could be in the existing screens, that would help a lot, I’d think.

You can Debugging Functions - #2 by Aaron_Moreng and bpm dump has been there forever. Also there is a new dump sources checkbox. Gives you the Epicor generated code.

I respect the idea but won’t cede it entirely. Both widgets and code can be incredibly unreadable. The generated code is not easily read either. I will cede @jgiese.wci’s point that we really can’t make readable widgets. It’s out of our control. We CAN make more readable code but not to the point of following basic Clean Code techniques. That’s also out of our control since we cannot make our own classes, test harnesses, etc. Not sure where one can go from here because we are limited in our scope. :person_shrugging:

Perfect is the enemy of good enough :man_shrugging:

1 Like

And those are great tools. But as a matter of convenience, I still plan to submit an Idea for making this visible in the client.

1 Like

With the ease of access to the externals folder and custom assemblies folders these days this is less of an issue, but it would be tops if we could define classes and even use those as types for things like functions… would be… sooo awesome

200w1

So here is my widget code translated to C# for creating a new user. But im still having issues enabling the new user it seems like my get by id is empty data set.

this.CallService<Ice.Contracts.UserFileSvcContract>(newUF =>{
  var dsNewUf = new Ice.Tablesets.UserFileTableset();
  string UserID = this.FirstName + "." + this.LastName;
  
  if(this.SiteList == "")
  {
    this.SiteList = "SEC01~SEC02";
  }
  newUF.GetNewUserFile(ref dsNewUf);
  dsNewUf.UserFile[0].UserID = UserID;
  dsNewUf.UserFile[0].Name = this.FirstName + " " + this.LastName;
  dsNewUf.UserFile[0].EMailAddress = this.Email ;
  dsNewUf.UserFile[0].DomainName = "SENTRY";
  dsNewUf.UserFile[0].OSUserID = this.FirstName + "." + this.LastName;
  dsNewUf.UserFile[0].PasswordBlank = true;
  dsNewUf.UserFile[0].PasswordEmail= "";
  dsNewUf.UserFile[0].PwdExpiresDays = 0;
  dsNewUf.UserFile[0].PwdExpires = DateTime.Today;
  dsNewUf.UserFile[0].PwdGrace = 3;
  dsNewUf.UserFile[0].UserDisabled = true; //Toggle User
  dsNewUf.UserFile[0].RowMod = "A";
  newUF.Update(ref dsNewUf);
  newUF.AddUserCompany(UserID, ref dsNewUf);
  dsNewUf.UserComp[0].UserID = this.FirstName + "." + this.LastName;
  dsNewUf.UserComp[0].Company = "SEC";
  dsNewUf.UserComp[0].Name = this.FirstName + " " + this.LastName;
  dsNewUf.UserComp[0].PlantList = this.SiteList;
  dsNewUf.UserComp[0].CompanyName = "Sentry Equipment Corp";
  dsNewUf.UserComp[0].RowMod = "A";
  newUF.Update(ref dsNewUf);
  this.UserID = UserID;
  this.ThisLib.EnableUser(this.UserID);
  }) ;

This is my code to Enable the user we are single sign on

this.CallService<Ice.Contracts.UserFileSvcContract>(uf =>{
  var dsUf = uf.GetByID("Devin123.Draeger");
  dataset = dsUf;
  dsUf.UserFile[0].ClearPassword = true;
  dsUf.UserFile[0].PasswordBlank = true;
  dsUf.UserFile[0].PasswordEmail = "";
  dsUf.UserFile[0].PwdExpiresDays = 0;
  dsUf.UserFile[0].PwdExpires = DateTime.Today;
  dsUf.UserFile[0].PwdGrace = 3;
  dsUf.UserFile[0].UserDisabled = false; //Toggle User
  dsUf.UserFile[0].RowMod = "U";
  uf.Update(ref dsUf);
  }) ;

So, are you saying it is working for you? I gave your post the :+1: but I don’t know if I am jumping the gun.

Lol the first part is working but not the second part. I cant seem to see why it is not working. I was able to use the updateext on swagger page to get it to work so i will try that next but i am close.

Not causing your problem, but I would still set this to false. Since you’re Windows SSO, you may want to set the SSO only flag too. Setting the password to blank would potentially allow anyone on the network to log in via SSL or net.tcp. Forcing SSO should block that. Best not to allow blank passwords IMHO.

So, the user “Devin123.Draeger” appears in User Account Security Maintenance? Just not enabled?

Yes the account is in user account maintenance correct and not enabled. I will try with updateext i was able to do that on the swagger app.

Yeah, since you could do it with Swagger my next suggestion wouldn’t apply and that is a Password Policy that doesn’t adhere to what you are entering.

@Mark_Wonsil @jgiese.wci

Wooo! Got it working.

Well, eventually the lightbulb clicked - I don’t need to enable the user in the Function. I can call the BO directly, since I know that works.

image

So, it needs some polish, and I’ll write it up in a separate post here, but this works in 2021.2 and 2022.2:

As for the original (actual) issue, I still don’t get why the update fails in any kind of function I made. Sorry @Devin.Draeger

Since yesterday, I have tried Ice vs Erp, Update vs UpdateExt, and a dozen other things. But if they don’t work and all I need is to do one more thing, I’ll just skip the Function for that part.

I’m Polish… :person_shrugging:

Hmm. :thinking:

I can’t tell you how long it took me to understand what “polish” had to do with RPN on HP calculators.

:bulb: Polish! With a capital P!

So i finally have it working now! I used a variation of this topic Auto-Disable User Accounts? - ERP 10 - Epicor User Help Forum (epiusers.help)

here is my code

this.CallService<Ice.Contracts.UserFileSvcContract>(uf =>{
  var dsEnableUf = new Ice.Tablesets.UpdExtUserFileTableset();
  var dsUf = uf.GetByID(userID);
  bool errorsOut = false; 
  var ufr = new UserFileRow();
  ufr.UserID = dsUf.UserFile[0].UserID;
  ufr.UserDisabled = false;
  ufr.RowMod = "U";
  dsEnableUf.UserFile.Add(ufr);
  uf.UpdateExt(ref dsEnableUf,false,true, out errorsOut);
}) ;
1 Like