Make the field "Unit Price" in page Sales Order Subform editable regarding the current user ?

Maddynav123
Member Posts: 12
Hi guys,
Please can you help me how make the field "Unit Price" in page Sales Order Subform editable regarding the current user with C/AL ?
Thank you.
Please can you help me how make the field "Unit Price" in page Sales Order Subform editable regarding the current user with C/AL ?
Thank you.
0
Answers
-
Can you express more clearly what do you want to achieve?
Every user logged to the system and using it is the "current user£, so if you want to make it editable for "current user" it means it should be editable for everyone.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
In table 91 User Setup I added a new field Allow Editing Unit Price (type Boolean) and also I create a function in table 91 that returns the value of the new field if the record exists for the current user, or FALSE if the record not exists.
IF "User ID" <> '' THEN BEGIN
IF UserSetup.GET(USERID) THEN BEGIN
AllowEditingUnitPrice := UserSetup."Allow Edit Unit Price";
EXIT(AllowEditingUnitPrice);
END;
END;
EXIT(FALSE);
In page 46 Sales Order Subform I shpuld make the field Unit Price editable regarding the current user setup for the new field. This is what I am trying to do.
0 -
Editable is no longer available on pages as a field property which can be changed at a runtime. You can make the entire subpage editable or not during runtime, but not an individual field.
You can get desired effect by adding a code throwing errors in Unit Price - OnValidate trigger on the pageUserSetup.GET(USERID) ; //will thow an error if user does not have UserSetup therefore no explicit permission are definied UserSetup.TESTFIELD("Allow Edit Unit Price", TRUE);
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-031 -
Thank you Slawek,
I add the code in Unit Price - OnValidate on Page.46 Sales Order Subform but again I can't edit it.
What can I do ?0 -
[Topic moved from 'NAV Tips & Tricks' forum to 'NAV Three Tier' forum]
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
The function is on the subform? The design of your solution is not quite clear.
Also, i suggest this soulltion. Add on subform new Boolean variable. And make code like this:OnOpenPage UserSetup.GET(USERID); OnAfterGetCurrRecord NewBoolean := UserSetup."Allow Edit Unit Price";
Then add variable NewBoolean in editable property "Unit Price" on subform.0 -
Adding UserSetup.GET(USERID) in OnOpenPage will result in blocking opening Sales Order form for anyone not having UseSetup rec defined. That's not the original requirement.Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
So he can do
OnOpenPage IF UserSetup.GET(USERID) THEN;
For get record only once without error.0 -
Hi,
First of all thank you for your support.
My finale version so far is:
- In T.91 User Setup I add a new field "Allow Edit Unit Price"-> Boolean
- In T.91 User Setup I create a new function: AllowEditingUnitPrice() : Boolean
AllowEditingUnitPrice() : Boolean
IF NOT GET(UPPERCASE(USERID)) OR (USERID = '') THEN
EXIT(FALSE);
EXIT("Allow Edit Unit Price");
- In Page 46: Sales Order Subform I did the following:
Unit Price - OnValidate()
UserSetup.GET(USERID);
UnitPriceEditable := TRUE;
UnitPriceEditable := UserSetup.AllowEditingUnitPrice;
PS: In the properties of Field Unit Price I make:
Editable : UnitPriceEditable
When I run the page, field "Unit Price" ( Which is shown as "Unit Price Excl. VAT" isn't Editable. I am using NAV 2017
Please what you advise me to do?
BR
MADDY
0 -
Function will return AllowEditingUnitPrice FALSE or value from field? But by default boolean fields returns false. And i don`t understand why you GET userID in UserSetup, if it is part of primary key and he will always be present.
Code on trigger OnValidate work only after value changed. So variable UnitPriceEditable = FALSE.
I would say that there is a lot of redundant code here. Function AllowEditingUnitPrice doesn't look necessary.
My solution for you:
In T.91 User Setup I add a new field "Allow Edit Unit Price"-> Boolean
On page 46 Sales Order SubformOnOpenPage IF UserSetup.GET(USERID) THEN UnitPriceEditable := UserSetup."Allow Edit Unit Price";
Add variable UnitPriceEditable in editable property.
So when you do not get userid in UserSetup, field will be NotEditable because boolean field by default return FALSE. Otherwise code will check in UserSetup value from field "Allow Edit Unit Price" and will replace.1 -
I must create a function in table 91 that returns the value of the new field if the record exists for the current user, or FALSE if the record not exists.
Is underlined for my issue.0 -
A boolean field in an uninitialized record variable (or more generally uninitialized boolean var) in NAV defaults to FALSE. After calling IF UserSetup.GET(USERID) THEN; added field "Allow Edit Unit Price" will be FALSE if UserSetup does not exist for a given USERIDSlawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-031
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