Creating and using an Edit method on a Datasource
I was wanting to emulate a "marking" of a record within a grid, similar to the way this is done when you settle a payment journal. Well I created a edit method of NoYes type on the InventTable datasource for the form I was working on. Seemed like it would work, and used the InventTable.RecId field, which is the datasource record, to store and base the return off of.
When I tried this though the grid kept acting strange. I would mark one, and then leave the record, which would then make the one below or above marked and not the one I just marked. I really scratched my head on this one and sent an email out to the Axapta Knowledge Villiage news group. An associate by the name of Steeve said that if I could get the current InventTable record passed in then I could make it work. He also stated that he could not get it to compile.
Well I messed around with this a little and found out the reason why my buddy Steeve could not get it to compile. Turns out, the boolean set must be the first variable passed in. Then the NoYes variable must be the Last (there is the key), and the passed in current record be between those two passed in variables. With this I was able to create an edit method that worked like the settle method and have the grid behave like it was suppose to.
Below is example code of the edit method and the correct way to achieve this:
edit NoYes MarkSKUs(boolean set,
InventTable Invent,
NoYes _markSKUs)
{
if (set)
{
MarkMap.insert(Invent.RecId,_markSKUs);
MarkMap.valueSet();
}
else
{
if (MarkMap.exists(Invent.RecId))
{
_markSKUs = MarkMap.lookup(Invent.RecId);
}
}
return _MarkSKUs;
}
Find a job at: www.DynamicsAXJobs.com
When I tried this though the grid kept acting strange. I would mark one, and then leave the record, which would then make the one below or above marked and not the one I just marked. I really scratched my head on this one and sent an email out to the Axapta Knowledge Villiage news group. An associate by the name of Steeve said that if I could get the current InventTable record passed in then I could make it work. He also stated that he could not get it to compile.
Well I messed around with this a little and found out the reason why my buddy Steeve could not get it to compile. Turns out, the boolean set must be the first variable passed in. Then the NoYes variable must be the Last (there is the key), and the passed in current record be between those two passed in variables. With this I was able to create an edit method that worked like the settle method and have the grid behave like it was suppose to.
Below is example code of the edit method and the correct way to achieve this:
edit NoYes MarkSKUs(boolean set,
InventTable Invent,
NoYes _markSKUs)
{
if (set)
{
MarkMap.insert(Invent.RecId,_markSKUs);
MarkMap.valueSet();
}
else
{
if (MarkMap.exists(Invent.RecId))
{
_markSKUs = MarkMap.lookup(Invent.RecId);
}
}
return _MarkSKUs;
}
Find a job at: www.DynamicsAXJobs.com
4 Comments:
There is a difference in the edit-method in a table and in a datasource, as you can read at http://msdn.microsoft.com/en-us/library/aa637541(AX.10).aspx
Thanks for that, but from where should I call the created edit method?
Hi,
A small query
why do we need the below statement
MarkMap.valueSet()
Thanks,
Priyan
@Priyan
I don't believe you need the "MarkMap.valueSet();"
That line should just return the Set from the map.
See here:
http://msdn.microsoft.com/en-us/library/aa591362(v=ax.10).aspx
Post a Comment
<< Home