Thursday 4 July 2013

Record Link List in Ax 2012


Hi Friends,

We have RecordLinkList which is used to store buffers of different tables in one go.

Here below is the example of how to use Record Lint List.



RecordLinkList recordLinkList;
;
recordLinkList = new RecordLinkList();

for (buffer = McsEmValConsumptionValidationView_DS.getFirst(true) ? McsEmValConsumptionValidationView_DS.getFirst(true) : McsEmValConsumptionValidationView_DS.cursor(); buffer; buffer = McsEmValConsumptionValidationView_DS.getnext())
{
if (buffer.CalculatedConsumptionValidUntilDate == FcsDateTimeAPI::DateNull())
{
recordLinkList.ins(buffer);
}
}

while retrieving you can use this

hasNext = recordLinkList.first();
while (hasNext)
{
common = recordLinkList.peek();
switch (common.TableId)
{
case tableNum(McsEmValConsumptionValidationView):
consValView = common;
calculatedConsumption = McsEmCalcCalculatedConsumption::find(consValView.CalculatedConsumptionId);
break;

case tableNum(McsEmValProcessErrorDetailInfo):
processErrorDetailInfo = common;
calculatedConsumption = McsEmCalcCalculatedConsumption::find(processErrorDetailInfo.CalculatedConsumptionId);
break;

default:
hasNext = recordLinkList.next();
continue;
}

Vivek Chirumamilla

Wednesday 5 June 2013

How to restrict combo Box Controls in Ax 2012

Hi Friends ,


Today we are going to see how to restrict combo Box Controls in Ax 2012

public FormComboboxControl removeInactiveInvoiceTypes(FormComboboxControl _formComboboxControl)
{
FormComboboxControl formComboboxControl;
DictEnum dictEnum;

MInvoiceTypeTable invoiceTypeTable ;
;

formComboboxControl = _formComboboxControl;

dictEnum = new DictEnum(enumNum(BilInvoiceTypes));

numberOfInvoiceTypes = dictEnum.values() - 1;

while select InvoiceType from invoiceTypeTable
where invoiceTypeTable.UseForFreeTextInvoice == noYes::No
{
formComboboxControl.delete(dictEnum.value2Label(invoiceTypeTable.InvoiceType));

numberOfInvoiceTypes--;
}

return formComboboxControl;
}

In the run Method element.removeInactiveInvoiceTypes(InvoiceType);


Vivek Chirumamilla

Sunday 7 April 2013

Query Dialog Fields Lookup in Classes in Ax 2012


Hi Friends,

Today we are going to do the query Lookup in dialog of classes because most of the clients would ask for this type of requirement.

Now we would place a customer Id lookup in the dialog. Declare QueryRun and Customer Id.
public void initParmDefault()
{
Query query;
;
super();
query = new Query();
query.addDataSource(tableNum(CustTable));
queryRun = new QueryRun(query);
}

public container pack()
{
;
return [#CurrentVersion, #CurrentList, queryRun.pack()];
}
public boolean unpack(container _packedClass)
{
Version version = runbase::getVersion(_packedClass);
Container packedQuery;
;
switch (version)
{
case #CurrentVersion:
[version, #CurrentList, packedQuery] = _packedClass;

if (packedQuery)
queryRun = new QueryRun(packedQuery);
break;

default:
return false;
}
return true;
}
public QueryRun queryRun()
{
;
return queryRun;
}
boolean showQueryValues()
{
;
return true;
}
By these above modification you can see Customer Id in the Query Dialog box.

Vivek Chirumamilla

Thursday 28 March 2013

Running the Wizrad through Code in Ax 2012

Hi Friends,

Today we are going to see how we can run the wizard through code.Just by clicking the button the wizard will run. We have a doubt what is the point of running the wizard automatically without providing values. We can also pass the values through code and run the wizard.

Here is a snipet of the existing functionality where a relation wizard is run between customer and connection.The relation wizard is called from a class.

Where we are going the run the wizard without Human Interaction .

Here are the steps below:

Cerate a new class and extend with sysWizard or your wizard which is running.


FormName formName()
{
return formstr(McsRelationWizard);
}

private void createRelation(CustAccount _custAccount , McsConnectionId _connectionId)
{
Form form;
Args argsLocal = new Args();
;
this.initFormRun();

form = formRun.form();
argsLocal.object(form);
argsLocal.caller(this);
formRun = classfactory.formRunClass(argsLocal);
formRun.init();
formRun.QcHandOver(_custAccount,_connectionId);
}
public static void main(CustAccount _custAccount , McsConnectionId _connectionId)
{
QcHandOverRelation wizard = new QcHandOverRelation();

;
wizard.createRelation(_custAccount,_connectionId);
wizard.run();

}



Vivek Chirumamilla

Friday 22 March 2013

Passing Information from to another based on Selection in Ax 2012


Hi Friends,

In my previous posts I had shown how to open a form in runtime , but opening the form in runtime is one aspect and passing the information to the base form based on user selections is another hurdle.

Today we are going to pass the customer from one form to another.

We have a customer field in a form and this customer has to be searched from another form where the list of customers are shown. User places the cursor on the serach and press use customer this selected customer must be returned to the cutomer field



To return the customer which we have selected , write doen the following code in the clicked method of the use customer.

void clicked()
{
;

element.args().parm(CustTable.AccountNum);

Element.close();

super();
}


While in the first form write the follwing code to open the form for selection and taking the value for the which has been returned.

void clicked()
{
FormRun formRun;
Args args;
AccountNum retValue;
;

args = new Args();
args.name(Formstr(McsCustomerSearch));
args.caller(element);

formRun = classFactory.formRunClass(args);
formRun.Init();

formRun.run();
formRun.wait();

if (args.parm())
{
retValue = args.parm();
CustomerId.text(retValue);
CustomerId.modified();
}
}

By this whatever value we have selected in the second form not only passes to the first form but also the value is diplayed in the current field.

Happy Daxing

Vivek Chirumamilla