web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / How to get value from ...
Finance forum

How to get value from control in form?

(0) ShareShare
ReportReport
Posted on by 3,805

Hi all..

i have case in form PurchCreateFromSalesOrder. in Sales Order --> Purchase Order.

i have 2 new field in SalesLine table (PIL_TransType, PIL_BasePrice) and i put this field in grid form PurchCreateFromSalesOrder.

the condition is, if i fill field PIL_TransType, so PIL_BasePrice automatic get value from control PurchasePrice.

control PurchasePrice use method in SalesLine datasource  --> specifyUnitPrice.

i try using events onModified, but i can't get value from control PurchasePrice.

so, how i can do it? how i can get value from control PurchasePrice.

Thanks.

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    301,146 Super User 2025 Season 2 on at

    Hi PIL,

    If I do understand it correctly, you want to fill the PIL_BasePrice at the moment you have changed the PIL_TransType. You can use the table method modifiedField() and add some logic.

    However what is the exact definition of your PurchasePrice? Is the sales order linked to a purchase order using e.g. reservations? The specifyUnitPrice method is not familiar in my environment.

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    If you want to get value from form control, you can call ControlName.realValue() if it's a real type field.

  • Suggested answer
    Sukrut Parab Profile Picture
    71,710 Moderator on at

    If  control uses data method  the you are going to get the same values by calling that data method  on sales line variable . In the modified event , if you are getting salesline variable in the modified event , which I think you can get ,just call that data method to get the value you want .

  • fajar Profile Picture
    3,805 on at

    Hi Andre,

    PurchasePrice is one name control in grid Form PurchCreateFromSalesOrder, and this control not use field in table SalesLine, but use method edit specifyUnitPrice() in dataSource SalesLine. So i can't use table method modifiedField().

    i want if i fill field PIL_TransType, PIL_BasePrice can get value from this control.

    so, if controlName PurchasePrice change value, PIL_BasePrice can save history real value before changes Price.

  • fajar Profile Picture
    3,805 on at

    Hi Nikolaos,

       i try use this events.

       [FormControlEventHandler(formControlStr(PurchCreateFromSalesOrder, SalesLine_PIL_TransType), FormControlEventType::Modified)]

       public static void SalesLine_PIL_TransType_OnModified(FormControl sender, FormControlEventArgs e)

       {

           FormRun         formRun = sender.formRun();

           FormDataSource  salesLine_ds = sender.formRun().dataSource();

           SalesLine       salesLine = salesLine_ds.cursor();

           FormControl     purcPrice = formRun.design().controlName("PurchasePrice");

           ;

           salesLine.PIL_BasePrice          = purcPrice.realValue();

       }

    i get error because "class 'FormControl' does not contain a definition for method 'realValue'.

    please help me, whats wrong?

    thanks.

  • fajar Profile Picture
    3,805 on at

    Hi Sukrut,

    i try for call data methods to get value what i want, but i can't.

    i can't call that data methods.

    can you share sample modified event for call data method?

    thanks.

  • Verified answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Try to use FormRealControl class instead of FormControl.

    Like:

    FormRealControl     purcPrice = formRun.design().controlName("PurchasePrice");

    Not 100% sure if the class name is FormRealControl or something slightly different (and I don't have a system at hand) but the point is that you need to use correct type of form control.

  • fajar Profile Picture
    3,805 on at

    Hi Nikolaos,

    Yes its work.

    i use FormRealControl class.

    Thanks.

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans