Announcements
plz somebody help me
*This post is locked for comments
You weren't very generous in words, but I assume that you have a form control bound to a data source and you would like to sometimes show the field as mandatory, depending on values of some other fields in the same record.
If my description is correct, try to write it by yourself next time.
If it isn't, you see that you have to provide more details if you want to get an answer.
Assuming that I understand what you want, the answer is that you can override the active() method of the data source and set the mandatory property to true of false for the active record based on any condition you like.
I did using the below code in active() but no changes occur
if(Ledgerjournaltable.category=="")
control.mandatory(true);
Hi Codehunter,
I made a quick demo based on Martin's suggestion and I can verify that it works on my DEV machine.
If you can't figure out what's wrong, consider posting some screenshots of your implementation here.
if your control is bound to a datasource field (i.e. your control has a table field behind)
you should not use the code as you are using. you should write code as under
if(!LedgerJournalTrans.category) { LedgerJournalTrans_DS.object(fieldNum(LedgerJournalTrans,YourFieldName)).mandatory(true); } else { LedgerJournalTrans_DS.object(fieldNum(LedgerJournalTrans,YourFieldName)).mandatory(false); }
Referring control directly [control.mandatory(true);] is not good because of following reason:
Referring to control is only suggested when control is not bound to Dataset. In that case AutoDecleration property of control should be YES.
I have to add that code in modified() method of the field or what?? And ledgerjournaltrans_ ds is that a buffer or what/?? Plz reply to me ASAP
modified() method of the field is executed when the user changes the value of the field. How would it help you to set the field as mandatory before user actually starts changing the value? It's no way to go.
ledgerjournaltrans_ ds is an object representing a form data source. As always, you'll learn more about them in the documentation: Form Data Sources.
you have to add code in active method of DataSource after super();
Better would be if you put your code at end of standard AX code.
ledgerjournaltrans_ds represents your datasource (see your previous reply you have it there)
I added that code but nothing works ;it just keeps that field not mandatory in modified() of selected field
Can you please show your code?
and where you have written your code?
the method is that the modified method of selected control
Modified()
{
if(LedgerJournaltable.Category=="Subcontractors")
LedgerJournalTable_ds.object(fieldnum(LedgerJournaltable,Ledger_worderid)).mandatory(true);
}
else
LedgerJournalTable_ds.object(fieldnum(LedgerJournaltable,Ledger_worderid)).mandatory(false);
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.
Jump in, show your community spirit, and win prizes!
Expanding mentorship, skilling, and AI innovation
These are the community rock stars!
Stay up to date on forum activity by subscribing.
CP04-islander 21
dekion 4
Virginia99 4