I’m setting up a tree element on a form I’ve created. I’m having no problem with setting up the tree but this is my first time writing methods for a form and I have no idea how to retrieve the data currently displayed on the form through X++.
How would I go about doing this?
hi,
Use element . args . record() which will help to get the record which is at present…You can write codings in init method or active method…
My tree will also need to be refreshed when the next record is loaded. Will this work in the nextrecord method as well?
Hi,
If u write the coding in active method, the code will help you the pick the data from the active record. To refresh, u need to use the function refreshEx() in ur coding…i.e treename.refreshEx();
I may not have understood this correctly. element.args().record() returns the record currently selected in the form? If so what format does it return it as?
I must really be misunderstanding this as the code given does not seem to even compile. Just to clarify I’m using dynamics ax 2012 and am just trying to retrieve a single value from a field on the form.
hi,
otherwise write a modified method of field where you selecting the value in the datasource level. in that declare the control name which should be refresh. have a lookup in this code. it may be helps you…
public void modified()
{
#define.blank(’’)
super();
// When segment changes, subsegment should be cleared
Te_BankGuarantee.SubsegmentId = #blank;
// Refersh Customer data source
Te_BankGuarantee_ds.refresh();
}
here blank is the macro and Te_Bankguaranteee is the tablename and subsegmentid is the control name in the form where you want to refresh the control when selecting the value in other control
Again I think I’m phrasing the question wrong. The data does not specifially need to be read from the form. The field is read only so will not be modified by the user. All I’m trying to find out is how I can access the data from the record that is currently being displayed.
All I need to know is how to access the currently active record.
Ah the original post was correct. I just misunderstood how the record is returned. Thanks for the help.
Hi,
You are confusing us…C…Record in the sense means, from table…correct?..which is displayed in the form…Can u tell me the form name as well as the datasource u are using which will be helpful to clarify your doubt…
The table is called proptable and the formname is propform. Both are custom.
The info you gave originally works, but only if the form is launched with arguments setting an initial record. If the form is launched without this it doesn’t work. For example it works when selecting a record from a list page but does not work if simply opening the form using a menu item.
Ideally I was looking for a way to read what record is being displayed regradless of if the form is launched with a record within args.
I’ve solved the problem.
Since the record was only retrieved if a record was given in args when the form is launched I have simply setup an if statement to check if a record is given.
If not then I run a statement to select the first record as this is loaded by the form as a default anyway.
//loads the propbuffer with a record from arguements if one is given
propBuffer = element.args().record();
//If no record was given in args loads the first record as a default
if(!propBuffer)
{
select firstOnly propBuffer;
}
}