Breaking news from around the world
Get the Bing + MSN extension
Now Available in Community - MBAS 2019 Presentation Videos
Catch the most popular sessions on demand and learn how Dynamics 365, Power BI, Power Apps, Power Automate, and Excel are powering major transformations around the globe. | View Gallery
2019 release wave 2 Discover the latest updates and new features to Dynamics 365 planned through March 2020
Release overview guides and videos Release Plan | View virtual launch event
Ace your Dynamics 365 deployment with packaged services delivered by expert consultants. | Explore service offerings
Connect with the ISV success team on the latest roadmap, developer tool for AppSource certification, and ISV community engagements | ISV self-service portal
The FastTrack program is designed to help you accelerate your Dynamics 365 deployment with confidence.
FastTrack Program | Finance TechTalks | Customer Engagement TechTalks | Talent TechTalks | Upcoming TechTalks
How to add real type fields. What syntax?Field ABS_sumAmountMST
Add where? To a table? Form? Report? Function? Integration? Could you share more details on what you are trying to achieve? Thanks!
In a form I am trying to sum fields using MultiSelectionHelper. Form name is CustTrans and sum field is AmountMST real type. How to correctly get sum of selected records(marking records, sum appears of real type field
The actual field should be an unbound Real control. That's how you add the field.
Next step is to get data in that field.
You already seem to know the multiSelectionHelper. So, you use that to iterate all the selected records and count together the sum of those records (mySumValue += custTrans.AmountMST inside the iteration loop).
Finally, you call MyField.realValue(mySumValue); where MyField is your sum field, and mySumValue is the variable where you have the sum qty.
How to define properly mySumValue expecting real type field in method.
Just use the same data type than the field that you are summing!
If you add multiple AmountMST values, it's still AmountMST. There's no special data type for "summed value", it's a number just like the amounts that you summed together.
How to set output setValue data to ABS_SumAmountMST field menu item. Given my code:
public real calculateSumAmountTransactCurrency()
MultiSelectionHelper helper = MultiSelectionHelper::construct();
custrans = helper.getFirst();
while (custrans.RecId != 0)
custrans = helper.getNext();
// ABS_SumAmountMST=sum(ABS_SumAmountMST, custrans.AmountMST);
// return ABS_SumAmountMST;
I already told you that in my first reply:
If your field is called MyField (and AutoDeclaration is Yes), you can set value to it like this:
What do you mean by "field menu item"?
By the way, your code misses the amount of the first custTrans. In your while statement you should call getNext only after handling the sum of the current custTrans (that you had when you first entered the while statement.
MyField.realValue(mySumValue) before return?
Your method doesn't need to return anything.
Or, if you want to, you can call MyField.realValue(element.calculateSumAmountTransactCurrency()); This code should not be inside your method (that would be an infinite loop), it should be where you trigger the sum calculation.
You know now how to calculate the sum, and how to set value to an unbounded field. How exactly you organize your code is up to you.
How to call other method in my published method. It called markChange which is overridden. Both methods are in data source custtrans datasource methods. One method is mark changed other is calculateSumAmountMST. How to call markchanged method in method calculateSumAmountMST
You should not call markChanged method, it's called automatically when the user selects record(s) in the form.
But you should call your calculateSumAmountMST from markChanged method (if you wish to run your method every time the mark is changed).
"How to call other method" works always the same way. "objectName.methodName()".
Since markChanged and calculateSumAmountMST are in the same object (the form data source), you can call it with "this.calculateSumAmountMST()".
How to pass returned sumValue for other method markChange and reset value. public void markChanged()
I think I already instructed you on that just a couple of messages above.
If you are now in markChanged method, you can use this code:
In general you can pass values by using "=" operator. For example if you want to pass number 5 to variable myNumber, you call myNumber = 5; It works just like in most other programming languages.
If you want to pass the return value of this.calculateSumAmountTransactCurrency() into the ABS_SumAmountMST.realValue() method, you use the solution that I provided above.
Finally, could you please use only relevant tags in your questions. Now you used tags like "Connector for CRM", "Windows 8 and Mobile Apps", "Forecaster and FRx", "Reporting and BI" and others, even if they are not related. In general this doesn't serve your purpose. But instead I encourage you to put effort in describing your problem already in your initial question. That way it's more likely that others can help you.
Business Applications communities