Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

Codeunit to modify page fields

(0) ShareShare
ReportReport
Posted on by 30

Hello guys. 
I’ve made a codeunit that does some stuff when a sales order is released…. 
i would like that codeunit to also modify some fields on the sales order page, so when it’s triggered I wanna make some fields not editable on the page “Sales Order”

i can’t find the key to make it work… I can’t insert a car called “test: page “Sales order””

in my optics it should be possible to browse the page test.testfield.editable = false

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,595 Super User 2024 Season 2 on at
    RE: Codeunit to modify page fields

    Hi, Hi, I think the problem is that you have to close the current page, set the Editable property, and reopen the page.

    pastedimage1651015117380v1.png

    Hope this helps.

    THanks.

    ZHU

  • RasmusAKEA Profile Picture
    RasmusAKEA 30 on at
    RE: Codeunit to modify page fields

    Yes indeed - i could use a field to change it with - actually i have that field already, when it changes to <> '' i must trigger something - basically i can't see how to do that on the PageExtension page - so far seems like ionly have access to the fields from that page. 

    So if i could make a Trigger when that record changes, i could then set the property of 3 other fields.... 

    But so far i can't get the Trigger to work lige i expect - and also when i do like this: 

    Modify(TestField)

    {

    trigger OnValidate()

    If TestField <> '' Then Begin

    rec.TestField2.Editable = False;

    End;

    Seems like i don't get allowed to edit another field inside the TestField.... Also i can't get my "OnValidate" Trigger to run - if i test with a message... Basically i need a trigger when a field is changed on the page - that can do events on the fields :) 

    The Post yzhums  posted, is almost what i want - but can't figure out to change as i want :) 

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 75,595 Super User 2024 Season 2 on at
    RE: Codeunit to modify page fields

    Hi, hope the following two posts can give you some new hints

    Switching a page to non-editable in real time via a field value

    https://yzhums.com/16756/

    The page mode that the page was opened in (Editable of the page)

    https://yzhums.com/9132/

    Thanks.

    ZHU

  • Suggested answer
    JAngle Profile Picture
    JAngle 46 on at
    RE: Codeunit to modify page fields

    Could you have an additional field? If the value is true it can control the page fields. Use a page extension and modify the visible property. You could also add a new global variable to a page extension and have it determined in the OnOpenPage trigger. Again using the value as the visible property for any fields

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans