[HELP] Modify only works with SQL db_owner

xina_man
Member Posts: 116
Hi there everyone!
I need to update a field on the item table and I'm using the code below on the OnRun() Trigger of a button placed in the item list form.
My problem is that the code above only works if the user as the db_owner permision. Otherwise it doesn't update the required field.
I've given the premision to RMID for the Item Table, sinchronized the user and it doesn't work...
Is there any problem with my code? How can I solve this issue?
Thans in advance
I need to update a field on the item table and I'm using the code below on the OnRun() Trigger of a button placed in the item list form.
Window.OPEN(Text001 + '@1@@@@@@@@@@@@\'); Window.UPDATE(1,0); TotalRecNo := Rec.COUNT; RecNo:=0; itemTable.RESET; itemTable.FIND('-'); itemTable.MODIFYALL("Qtd Calculo Necessidades", 0); Rec.FIND('-'); REPEAT Rec.CALCFIELDS(Inventory2); Rec.VALIDATE("Qtd Calculo Necessidades", Inventory2); Rec.MODIFY; RecNo+=1; Window.UPDATE(1, ROUND(RecNo/TotalRecNo*10000,1)); UNTIL Rec.NEXT = 0; FORM.RUN(50069);
My problem is that the code above only works if the user as the db_owner permision. Otherwise it doesn't update the required field.
I've given the premision to RMID for the Item Table, sinchronized the user and it doesn't work...
Is there any problem with my code? How can I solve this issue?
Thans in advance
0
Comments
-
No you don't need db_owner to be able to modify data in tables. All that regular NAV users need on SQL Server is 'public', db_owner is only for users who need to make object changes. You need to make sure that the user has proper permissions through their role assignments.0
-
Or, that Security is synchronized in NAV Client"A bove maiore discit arare minor"-"From the old ox, the young one learns to plow."0
-
DenSter wrote:No you don't need db_owner to be able to modify data in tables. All that regular NAV users need on SQL Server is 'public', db_owner is only for users who need to make object changes. You need to make sure that the user has proper permissions through their role assignments.
But the role is updated and the user is synchronized...
I've given the SUPER role to the user, after that synchonized him and it still doesn't work...
It only works properly after I give him the db_owner permission. I know it is strange... I hope that someone in mibuso can give me a possible solution for this...
Thanks0 -
And can you post the exact error you get when trying with no db_owner permissions? ;-)0
-
kine wrote:And can you post the exact error you get when trying with no db_owner permissions? ;-)
The problem is that I dont get an error message.
The Field that I want to modify doesn't get updated... after the routine it stays just as it was before.
If I give the db_owner permission the field is updated.0 -
When you loop a table and change some fields in each record, it is best to use an extra record-variable
I changed your code to do this:Window.OPEN(Text001 + '@1@@@@@@@@@@@@\'); Window.UPDATE(1,0); TotalRecNo := Rec.COUNT; RecNo:=0; itemTable.RESET; // NO NEED TO DO A FIND: itemTable.FIND('-'); itemTable.MODIFYALL("Qtd Calculo Necessidades", 0); Rec.FIND('-'); // or better : Rec.FINDSET(TRUE,TRUE); REPEAT rec2YourTable := Rec; rec2YourTable.CALCFIELDS(Inventory2); rec2YourTable.VALIDATE("Qtd Calculo Necessidades", Inventory2); rec2YourTable.MODIFY; RecNo+=1; //> this is for performance : update the dialogbox each 100 records. IF RecNo DIV 100 = 0 THEN //< this is for performance Window.UPDATE(1, ROUND(RecNo/TotalRecNo*10000,1)); UNTIL Rec.NEXT = 0; Window.CLOSE; // best to close the dialogbox before running a form FORM.RUN(FORM::"Your Form"); // best use this instead of the ID. It makes upgrading easier
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
kriki wrote:When you loop a table and change some fields in each record, it is best to use an extra record-variable
I changed your code to do this:Window.OPEN(Text001 + '@1@@@@@@@@@@@@\'); Window.UPDATE(1,0); TotalRecNo := Rec.COUNT; RecNo:=0; itemTable.RESET; // NO NEED TO DO A FIND: itemTable.FIND('-'); itemTable.MODIFYALL("Qtd Calculo Necessidades", 0); Rec.FIND('-'); // or better : Rec.FINDSET(TRUE,TRUE); REPEAT rec2YourTable := Rec; rec2YourTable.CALCFIELDS(Inventory2); rec2YourTable.VALIDATE("Qtd Calculo Necessidades", Inventory2); rec2YourTable.MODIFY; RecNo+=1; //> this is for performance : update the dialogbox each 100 records. IF RecNo DIV 100 = 0 THEN //< this is for performance Window.UPDATE(1, ROUND(RecNo/TotalRecNo*10000,1)); UNTIL Rec.NEXT = 0; Window.CLOSE; // best to close the dialogbox before running a form FORM.RUN(FORM::"Your Form"); // best use this instead of the ID. It makes upgrading easier
Thank you for your reply.
I've made those changes but unfortunately my problem continues...
It doesn't update the required Item table field...
But, by the way, thank you for those programing guidelines!0 -
Run the code with the client monitor and check what "itemTable.MODIFYALL("Qtd Calculo Necessidades", 0);" does (=what query does it send to SQL).Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions