When creating a sales order and adding lines to the order, I'd like to set our Sales Price field to not be editable based on certain criteria. I have a solution in place to not edit that field after it's been created, but I need a solution for users to not edit that field while it's being created. Here's what I've done so far to the form SalesTable......
- Set the AutoDeclaration property to Yes on the grid's SalesPrice object.
- Created a form method with the following code:
void FJEdisableSalesPriceEdit()
{
str modelGroupId;
str itemId;
itemId = SalesLine.ItemId;
modelGroupId = inventModelGroupItem::modelGroupId(ItemId,'fje');
if (modelGroupId == 'Std Cost')
{
salesLine_ds.object(fieldNum(SalesLine,SalesPrice)).allowEdit(false);
}
else
{
salesLine_ds.object(fieldNum(SalesLine,SalesPrice)).allowEdit(true);
}
salesLine_ds.refresh();
}
- There was already an Active override method created previously in the SalesLine data source. I added the following line of code to it just before return ret;
element.FJEdisableSalesPriceEdit();
Again, this works fine after I've created the line, then go back to edit it. I just need it to work when created it. I can't set the AllowEditOnCreate property to No on the SalesPrice field of the SalesLine table. Is there a way I can conditionally set this property in X++ using similar syntax from above? Thank you in advance for your help.
Travis