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

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Calling itemId modified method

(1) ShareShare
ReportReport
Posted on by 150
Hi,
 
I created a field on SalesQuotationLine. When filled, then I want to auto populate ItemId based on some logic.
 
At first, i wrote the code on the modified field of the table to auto populate itemId and it worked. But the other fields that gets populated automatically when filling the ItemId manually weren't filled (like salesCategory, procurment category..etc)
 
So in the modified field method, after filling the ItemId, i called this.modified(fieldNum(SalesQuotationLine,ItemId));
 
But it still didn't work. Then i noticed there is code on the modified method of itemId on the formDatasource itself.
 
So I moved my auto populating code to the formDatasource level instead of table level and called the modified method of the formDatasource. And indeed, it started filling itemId and the other fields when filling this new field. But somehow it cleared the new field that i fill (it seems there is code that clears the line when calling the modified method of the form datasource) so i had to store the original value of the new field and fill it again after calling the modified method. Is there another way?
 
[ExtensionOf(FormDataFieldStr(SalesQuotationProjTable, SalesQuotationLine, NewField))]
 final class SalesQuotationLineFDS_NewField_Extension
 { 
 public void modified()
 { 
 FormDataObject formDataObject = any2Object(this) as formDataObject;
 FormDataSource formDataSource = formDataObject.datasource();
 SalesQuotationLine salesQuotationLine = formDataSource.cursor();

 NewField newField = salesQuotationLine.NewField;
 
next modified();

 formDataSource.object(fieldNum(salesQuotationLine, ItemId)).modified();
 
salesQuotationLine.NewField = newField; 

 }
}
 
 
Categories:
I have the same question (0)
  • Martin Dráb Profile Picture
    238,732 Most Valuable Professional on at
    If I was you, I would debug ItemId.modified() to see where the value disappears.
     
    By the way, you can simplify your code by accessing form variables through the element variable.
  • CU22120935-0 Profile Picture
    150 on at
    Hi Martin,

    where to use "element" can you please explain further?
    ​​​​​​​
    Also that's the code causing it, but i can't skip it that's why i assigned the value again after calling the modified method.
    but i wanted to see if there's a better approach
  • Suggested answer
    Martin Dráb Profile Picture
    238,732 Most Valuable Professional on at
    If you're sure that keeping NewField value even after resetting the quotation line is the right approach, create an extension of SalesQuotationTableForm.resetSalesQuotationLine(), remember the value before next and put it to _salesQuotationLine again after next. I found this code by looking inside reReadSalesQuotationLine(); you should have done that too to understand the current logic and to be able to design a solution.
     
    Regarding element, you can use it in data source and data source fields extensions to access form variables, including those automatically created for data sources or so. For example, element.vendAdvanceInvoiceTable gives you the current record of VendAdvanceInvoiceTable data source.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 592 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 311

#3
Diego Mancassola Profile Picture

Diego Mancassola 269

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans