Sunday, May 8, 2016

Change design of Document report

I had to change the design of PO report today and I followed the usual way of mentioning my design in the controller class.
But then realized that it's not working and found that I need to make a change of design from the "FormLetterReport" class.

There is a method named "loadPrintSettings" where you can mention the design change for these document report like PO, GRN etc.

Wednesday, April 27, 2016

Filter on display method using context method

You may find a lot of codes for the same purpose but the one which worked flawlessly for me is written below:

Write the below code in the executeQuery method of the root DS:

public void executeQuery()
{
super();

if(!queryObj)
{
queryObj = true;
existQuery = new Query(this.query());
existQuery.saved();
remFilQuery = new Query();
remFilQuery = existQuery;
remFilQuery = existQuery.makeCopy();
}
}

Now the context method in the display method control:
public void context()
{
int selectedMenu;
formrun fr;
Args ag;
Name strtext;
str filSel = ”;
querybuilddataSource qb1, qb2, qb3;
queryrun qr;
query q, q2;
PopupMenu menu = new PopupMenu(element.hWnd());
int a = menu.insertItem(‘Filter by field’);
int b = menu.insertItem(‘Filter by selection’);
int c = menu.insertItem(‘Clear’);
;

selectedMenu = menu.draw();
switch (selectedMenu)
{
case a: //Filter by field
ag = new args(‘SysformSearch’);
fr = new formrun(ag);
fr.run();
fr.wait();

//Reading User entered value for filter process
strtext = fr.design().controlName(‘FindEdit’).valueStr();
//strtext = ‘”‘ + fr.design().controlName(‘FindEdit’).valueStr() + ‘”‘;
if(strtext)
{
//Creating a query for filter
q = new Query(InventSerial_ds.query());
// existQuery = InventJournalTrans_ds.query();

qb1 = q.dataSourceTable(tablenum(InventSerial));

qb2 = qb1.addDataSource(TableNum(EcoResProduct));
qb2.addLink(FieldNum(InventSerial,ItemId),FieldNum(EcoResProduct,DisplayProductNumber));

qb3 = qb2.addDataSource(tableNum(EcoResProductTranslation));
qb3.relations(true);

qb3.addRange(fieldNum(EcoResProductTranslation, Name)).value(strtext);
qb3.addRange(fieldNum(EcoResProductTranslation, LanguageId)).value(infolog.language());

InventSerial_ds.query(q);
InventSerial_ds.executeQuery();

}

break;

case b: // Filter By Selection3

q = new Query(InventSerial_ds.query());

qb1 = q.dataSourceTable(tablenum(InventSerial));

qb2 = qb1.addDataSource(TableNum(EcoResProduct));
qb2.addLink(FieldNum(InventSerial,ItemId),FieldNum(EcoResProduct,DisplayProductNumber));

qb3 = qb2.addDataSource(tableNum(EcoResProductTranslation));
qb3.relations(true);

filSel = ‘”‘ + ItemDesc.valueStr() + ‘”‘;

qb3.addRange(fieldNum(EcoResProductTranslation, Name)).value(filSel);
qb3.addRange(fieldNum(EcoResProductTranslation, LanguageId)).value(infolog.language());

InventSerial_ds.query(q);
InventSerial_ds.executeQuery();

break;

case c : // Remove Filter

InventSerial_ds.query(remFilQuery);
InventSerial_ds.executeQuery();

break;

Default:
break;
}
}

Credits: https://msddax.wordpress.com/2014/11/29/filter-on-the-display-method-using-context-method/

Tuesday, April 26, 2016

Multiple designs in Print Mgmt

I had to attach a new design to the Product Receipt report (PurchPackingSlip) which would run through a new menu item.

I tried to override the design by checking the calling menu item in the controller class but it always seemed to be picking from Print Management setup. Then I came across this:

If you have new formats for Sales/Purchase/Quotation confirmation/Picking/Packing/Invoice..., following these steps :

Step1. Create new Design for report under visual studio.

Step2. Add code to method:
\Data Dictionary\Tables\PrintMgmtReportFormat\Methods\populate
Add code  before TTSCOMMIT:
addOther(PrintMgmtDocumentType::SalesOrderPackingSlip, ssrsReportStr(SalesPackingSlip, ReportUD), ssrsReportStr(SalesPackingSlip, ReportUD), #NoCountryRegionId);    

Step 3. Choose you new format under:
AR -> setup -> form setup -> Print management -> Sales order Packing slip original -> report format to  SalesPackingslip.ReportUD

Step 4.
New Report design can be executed from use Print management from Inquiry journal forms or during posting by selecting Print management destination.

Step 5. (Optional)
In case: the report still keep original design, add this code to class TradeDocumentReportController in method outputReport:
//original menu item or your new menu item
if(args.menuItemName() == menuitemOutputStr(SalesPackingSlipOriginal))
{
formLetterReport.getCurrentPrintSetting().parmReportFormatName(ssrsReportStr(SalesPackingSlipOriginal, ReportUD));
}

Credits: http://axvuongbao.blogspot.in/2014/04/how-to-add-multiple-report-design-under.html

Thursday, March 31, 2016

Remove HTML tags of Text in EP

I had to retrieve a text value stuck in HTML tags. It was the JobAdText field in HRMRecruitingJobAd table. This field has values like "<BODY>Some description</BODY>" and I had to get the value "Some description".

You can use the below code:

Literal jobAd = this.rightGroup.FindControl("html_JobAd") as Literal;
jobAd.Text = HtmlUtilities.CleanupUnsafeHtml((string)currentJobAdRecord.GetFieldValue("HRMRecruitingJobAd!jobAdText"));

You can take the reference from the standard web control "HcmEPOpenJobsListPagePreviewPart" where the same code is used.

Suggestions and feedback welcome :)

Navigation pane issue in EP

I faced an issue with a new web control (put on Employee Services) which was showing Navigation pane when viewed through Employee Services module but when user goes to some other page and come back the navigation pane was not visible.

The problem looked weird that why would a page do it when the "Module" property on the PageDef was set to Home\EmployeeService!

But in both the cases the URL opening was different. Below are both URLs:
Working:
http://server/sites/DynamicsAx/EmployeeServices/Enterprise%20Portal/Ale_HcmOpenJobs.aspx?WMI=Ale_HcmOpenJobs&WebModuleName=Home%5cEmployeeServices%5cOrganization&WCMP=GCO&WDPK=initial

Non-Working:
http://server/sites/DynamicsAx/EmployeeServices/Enterprise%20Portal/Ale_HcmOpenJobs.aspx?WMI=Ale_HcmOpenJobs&WCMP=GCO&WDPK=initial

So I found a solution which I must say can be a workaround with no other impact.

Just go and set the "ShowParentModule" property to "No" on the node of the WebMenu where the control is added and it will work.

Tuesday, March 22, 2016

Repeat table header SSRS

Sounds easy going by the usual way of Tablix properties and check the "Repeat header rows on each page". Strangely this didn't work for me today so I found out a new way for same.

Under Design Pane - > at the bottom Column Groups - > click on drop down (down arrow) - > Advanced Mode.



Once we selected Advanced Mode, we will be able to notice (static) in Row Groups and Column Groups at the bottom of Design pane .



Under Design Pane - > Row Groups - > click on (static) - > Press F4 - > Properties window will pop-up.

In the Properties window - >Set KeepWithGroup = After and RepeatOnNewPage = True.

If you want the header to be frozen while scrolling down the report, set FixedData = True.




Credit: http://social.technet.microsoft.com/wiki/contents/articles/19398.ssrs-how-to-repeat-headers-on-each-page.aspx

Tuesday, March 8, 2016

Disable/Hide Modules from Ax2012

Today I found an interesting way to disable modules from AX for all users. One of our clients had asked us to do so for them. There are ways which we all are aware of like disabling configuration keys, disable licenses or maybe through code.

I had simply put a different country code (other than the base country) to the modules need to be hidden. When we do this those modules will only be available to that specific country whose code is attached. So this worked perfectly in our case. :)