How to disable&enable an account by adapter

Hi,guys,did anyone know how to disable&enable an account by adapter?

i tried this code
UserFileAdapter objAdpt = new UserFileAdapter(Program.IL);
objAdpt.BOConnect();
//objAdpt.GetByID(“jhzou”);

        objAdpt.GetData("jhzou");

        objAdpt.UserFileData.Tables["UserFile"].Rows[0]["UserDisabled"] = "1";

but no work ,it seems not like this part functions
PartAdapter adpPart = new PartAdapter(this.oTrans);
adpPart.BOConnect();
adpPart.GetByID(“PART0001”);

string PartDescription = adpPart.PartData.Tables[“Part”].Rows[0][“PartDescription”];

adpPart.PartData.Tables[“Part”].Rows[0][“PartDescription”]=“PART0001 xxxxxx”;
adpPart.Update();

adpPart.Dispose();

I am completely lost. What does PartAdapter have to do with any of this?

Also, an exact error would be helpful.

oh,Sorry to have misunderstood you,i’m trying with this code

UserFileAdapter objAdpt = new UserFileAdapter(Program.IL);
objAdpt.BOConnect();
objAdpt.GetByID(“U01J”);

        objAdpt.UserFileData.Tables["UserFile"].Rows[0]["UserDisabled"] = "false";
        
        objAdpt.Update();
        objAdpt.Dispose();

but thrown an exception :“You are not allowed to modify payroll manager privileges.”
why was that happend? Thanks

Do you get the same error if you go into User Maintenance and disable to the same user manually?

Also, the user account you are doing this from (running the custom) is a Security Manager?

2 Likes

Well,Thanks for replied,when i running it in Visual studio 2017 an error occurred,:“You are not allowed to modify payroll manager privileges”,but running it in Epicor customization working well.have you been try it in Vs2017?

Did you try another user that is not a Payroll Manager? Because you can’t disable a Payroll Manager, you would first have to mark them as not a payroll manager.

i tried another user for test,but still error :"“You are not allowed to modify payroll manager privileges”" by the way this error msg happened in Visual Studio ,same code Copy to Epicor
customization was working well.that’s very weird.

code reference:
UserFileAdapter objAdpt = new UserFileAdapter(Program.IL);
objAdpt.BOConnect();
objAdpt.GetByID(“TestUser”);

        objAdpt.UserFileData.Tables["UserFile"].Rows[0]["UserDisabled"] = "false";
        
        objAdpt.Update();
        objAdpt.Dispose();

Sorry for necroposting, but was a solution ever found for this? We are trying to simplify our label printing and store a default path on the user itself, and update it based on a selected printer. Currently we have some overengineered system making a printer identical in name to the user and then copying the path from a physical printer to the “user printer”. We want to cut out all the middlemen and just say, hey, this user uses this printer.

I’m getting this same issue in an updatable BAQ, but would be fine through customization, bpm, etc, I just can’t seem to find a solution.

Instead of using Erp.BO.UserFile, use Ice.BO.UserFile.
In the case of using UpdateExt, you cannot pass the UserComp info (lest you want GetNewUserComp is deprecated message - you have call AddCompany to finish it up)