Hi Folks,
Recently i got a requirement like Users want to see table name without development permissions.
Is it possible......what ever requirement we have to say yessssssssss only
From base i checked through debugger and i found some interesting facts.
1) Users unable to see Table name from personalization form.
2) Who have development permissions he only can able to see Table name from personalization form.
In SyssetupForm-- init() restricting personalization permissions.
See above screen in that when showDevInfo = True then only we can see personalization form.
When user become developer then only it will return TRUE otherwise false.
False means it will show any Table name in personalization form.
To overcome this i created new Table with 2 fields.
1) userID
2) Access (Enum- Noyes)
after this i created new form for this.
Here logic is which users want to see personalization permissions we can add newly created form.
and i passed this to personalization form.
If user is available in this newly created form.
showDevInfo = True problem solved.
14 Nov 2016
7 Sept 2016
17 Aug 2016
4 Aug 2016
Check Employee dimension through code + AX 2012
Hi Folks,
Recently my client face problem with Employee dimension.
Issue::
My client doing some functionality for that employee required some mandatory dimensions( Branch , Segment, Projects, BusinessUnits) but some employees don't have dimensions.
There are almost 2000 employees, it's not a easy task to check every employee for dimensions,
For that he asked me write a job for who don't have particular dimensions ( Branch , Segment, Projects, BusinessUnits).
Solution::
static void ExplorerGetdefaultdim(Args _args)
{
HcmEmployment hcmEmployment,hcmEmploymentloc;
str id;
str res;
boolean checkproj= true;
boolean checkbranch= true;
boolean checksegme= true;
boolean checkbussunit = true;
DimensionAttributeValueSetStorage dimStorage;
Counter i;
while select * from hcmEmployment where hcmEmployment.DefaultDimension != 0
// some employees don't have any dimensions i m not bothering about who don't have any //dimensions
{
select hcmEmploymentloc order by hcmEmploymentloc.RecId desc where hcmEmploymentloc.Worker == hcmEmployment.Worker;
checkbranch= true;
checksegme= true;
checkbussunit = true;
dimStorage = DimensionAttributeValueSetStorage::find(hcmEmploymentloc.DefaultDimension);
checkproj= true;
for (i=1 ; i<= dimStorage.elements() ; i++)
{
//info(strFmt("Worker :%1,Dimension :%2,Value :%3",hcmEmployment.Worker,DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name +"----" +dimStorage.getDisplayValueByIndex(i))); // if u want to see employee all dimensions
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Branch")
{
checkbranch = false;
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Segment")
{
checksegme =false;
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Projects")
{
checkproj =false;
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "BusinessUnits")
{
checkbussunit = false;
}
}
if(checkbussunit == true ||checkproj == true|| checkbranch == true ||checksegme == true)
{
info(strFmt("Errors result %1",HcmWorker::find(hcmEmployment.Worker).name()));
}
}
}
Recently my client face problem with Employee dimension.
Issue::
My client doing some functionality for that employee required some mandatory dimensions( Branch , Segment, Projects, BusinessUnits) but some employees don't have dimensions.
There are almost 2000 employees, it's not a easy task to check every employee for dimensions,
For that he asked me write a job for who don't have particular dimensions ( Branch , Segment, Projects, BusinessUnits).
Solution::
static void ExplorerGetdefaultdim(Args _args)
{
HcmEmployment hcmEmployment,hcmEmploymentloc;
str id;
str res;
boolean checkproj= true;
boolean checkbranch= true;
boolean checksegme= true;
boolean checkbussunit = true;
DimensionAttributeValueSetStorage dimStorage;
Counter i;
while select * from hcmEmployment where hcmEmployment.DefaultDimension != 0
// some employees don't have any dimensions i m not bothering about who don't have any //dimensions
{
select hcmEmploymentloc order by hcmEmploymentloc.RecId desc where hcmEmploymentloc.Worker == hcmEmployment.Worker;
checkbranch= true;
checksegme= true;
checkbussunit = true;
dimStorage = DimensionAttributeValueSetStorage::find(hcmEmploymentloc.DefaultDimension);
checkproj= true;
for (i=1 ; i<= dimStorage.elements() ; i++)
{
//info(strFmt("Worker :%1,Dimension :%2,Value :%3",hcmEmployment.Worker,DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name +"----" +dimStorage.getDisplayValueByIndex(i))); // if u want to see employee all dimensions
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Branch")
{
checkbranch = false;
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Segment")
{
checksegme =false;
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "Projects")
{
checkproj =false;
}
if(DimensionAttribute::find(dimStorage.getAttributeByIndex(i)).Name == "BusinessUnits")
{
checkbussunit = false;
}
}
if(checkbussunit == true ||checkproj == true|| checkbranch == true ||checksegme == true)
{
info(strFmt("Errors result %1",HcmWorker::find(hcmEmployment.Worker).name()));
}
}
}
21 Jul 2016
Create Worker through X++ in AX 2012
Today i got a requirement like create worker through code.
Through below job we can create very simple way.
29 Jun 2016
Get Individual dimensions from default dimensions + ax 2012
HI All,
Recently i got requirement like display Individual dimensions from default dimensions in purchase order.
These Individual dimensions i need to show in SSRS report.
protected Description GetDefaultDimensionAttributeName(DimensionDefault _dimensionDefault)
{
DimensionAttributeValueSetStorage dimStorage;
DimensionDefault HcmPositionDefaultDimension;
DimensionAttribute DimensionAttribute;
Counter i;
DimensionAttribute dimAttr;
DimensionAttributeValue dimAttrValue;
Common common;
DictTable dictTable;
str Name,Namecmp;
str value;
// make the dimension storage object
dimStorage = DimensionAttributeValueSetStorage::find(_dimensionDefault);
for (i=1 ; i<= dimStorage.elements() ; i++)
{
// get attribute select here.
select firstonly dimAttrValue
where dimAttrValue.RecId == dimStorage.getValueByIndex(i)
join dimAttr
where dimAttr.RecId == dimAttrValue.DimensionAttribute;
if (dimAttr && dimAttrValue)
{
dictTable = new DictTable(dimAttr.BackingEntityType);
common = dictTable.makeRecord();
if (common.TableId)
{
select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;
Namecmp = dimAttr.Name;
//My requirement like i want only BusinessUnit dimensions
if(Namecmp like "BusinessUnit")
{
name = common.(dimAttr.NameAttribute); //Dimension Description
value = common.(dimAttr.ValueAttribute); //Dimension Value
}
}
}
}
return name;
}
Recently i got requirement like display Individual dimensions from default dimensions in purchase order.
These Individual dimensions i need to show in SSRS report.
protected Description GetDefaultDimensionAttributeName(DimensionDefault _dimensionDefault)
{
DimensionAttributeValueSetStorage dimStorage;
DimensionDefault HcmPositionDefaultDimension;
DimensionAttribute DimensionAttribute;
Counter i;
DimensionAttribute dimAttr;
DimensionAttributeValue dimAttrValue;
Common common;
DictTable dictTable;
str Name,Namecmp;
str value;
// make the dimension storage object
dimStorage = DimensionAttributeValueSetStorage::find(_dimensionDefault);
for (i=1 ; i<= dimStorage.elements() ; i++)
{
// get attribute select here.
select firstonly dimAttrValue
where dimAttrValue.RecId == dimStorage.getValueByIndex(i)
join dimAttr
where dimAttr.RecId == dimAttrValue.DimensionAttribute;
if (dimAttr && dimAttrValue)
{
dictTable = new DictTable(dimAttr.BackingEntityType);
common = dictTable.makeRecord();
if (common.TableId)
{
select common where common.(dimAttr.KeyAttribute) == dimAttrValue.EntityInstance;
Namecmp = dimAttr.Name;
//My requirement like i want only BusinessUnit dimensions
if(Namecmp like "BusinessUnit")
{
name = common.(dimAttr.NameAttribute); //Dimension Description
value = common.(dimAttr.ValueAttribute); //Dimension Value
}
}
}
}
return name;
}
4 May 2016
Remove special characters using X++ in AX 2012
Just use the below code to remove the special character from the string.
23 Mar 2016
Based on parameters change SSRS Report Design + AX 2012
Hi Folks,
Recently i got a requirement like based on input parameters change report Design In SSRS.
We can get through Controller class.
For this i wrote code like this see below code snippers
public static void main(Args _args)
{
CLD_POController controller = new CLD_POController();
controller.parmReportName(ssrsReportStr(CLD_PO_DetailsReport,WithDetails)); //Default design
controller.parmArgs(_args);
controller.startOperation();
}
protected void preRunModifyContract()
{
Cld_POReportContract dataContract = this.getDataContractObject() as Cld_POReportContract; //contract class
if (dataContract.parmNoYes()) //if my check box Yes
{
this.parmReportContract().parmReportName(ssrsReportStr(CLD_PO_DetailsReport,
WithDetails)); //design 1
}
else //if my check box NO
{
this.parmReportContract().parmReportName(ssrsReportStr(CLD_PO_DetailsReport,
WithoutDetails)); //design 2
}
//super();
}
Recently i got a requirement like based on input parameters change report Design In SSRS.
We can get through Controller class.
For this i wrote code like this see below code snippers
public static void main(Args _args)
{
CLD_POController controller = new CLD_POController();
controller.parmReportName(ssrsReportStr(CLD_PO_DetailsReport,WithDetails)); //Default design
controller.parmArgs(_args);
controller.startOperation();
}
protected void preRunModifyContract()
{
Cld_POReportContract dataContract = this.getDataContractObject() as Cld_POReportContract; //contract class
if (dataContract.parmNoYes()) //if my check box Yes
{
this.parmReportContract().parmReportName(ssrsReportStr(CLD_PO_DetailsReport,
WithDetails)); //design 1
}
else //if my check box NO
{
this.parmReportContract().parmReportName(ssrsReportStr(CLD_PO_DetailsReport,
WithoutDetails)); //design 2
}
//super();
}
18 Mar 2016
Create Transfer Order through code + AX 2012
Today I came to across one requirement like Create transfer order through code.
I find out some useful code and try to use that code. It's working fine means i am able to create transfer order.
see below code for your reference.
Code
static void Job11(Args _args)
{
InventTransferTable inventTransferTable;
InventTransferLine inventTransferLine;
NumberSequenceReference numberSequenceReference;
NumberSeq numberSeq;
ProdBOM prodBOM;
InventTable inventTable;
;
ttsBegin;
inventTransferTable.clear();
inventTransferTable.initValue();
inventTransferTable.TransferId = "000021";
inventTransferTable.InventLocationIdFrom = "32";
inventTransferTable.modifiedField(fieldNum(InventTransferTable,InventLocationIdFrom));
inventTransferTable.InventLocationIdTo = "11";
inventTransferTable.modifiedField(fieldNum(InventTransferTable,InventLocationIdTo));
inventTransferTable.TransferStatus = InventTransferStatus::Created;
inventTransferTable.initFromAddress();
inventTransferTable.initValue();
inventTransferTable.initToAddress();
inventTransferTable.insert();
if(inventTransferTable)
{
inventTransferLine.clear();
inventTransferLine.initFromInventTransferTable(inventTransferTable,
NoYes::Yes);
inventTransferLine.ItemId = "A0001";
inventTable = InventTable::find(InventTransferLine.ItemId);
inventTransferLine.initFromInventTable(InventTable);
inventTransferLine.initFromInventTable(InventTable::find("A0001"));
inventTransferLine.initFromInventTransferTable(inventTransferTable,false);
inventTransferLine.QtyTransfer = 2;
inventTransferLine.QtyShipNow = 0;
inventTransferLine.QtyReceiveNow = 0;
inventTransferLine.QtyRemainShip = 1;
inventTransferLine.QtyRemainReceive = 1;
inventTransferLine.insert(NoYes::Yes);
}
ttsCommit;
}
Successfully created but I find out some issues like
1) when I am try to posting, posting buttons disabled. But when I try to create transfer order from
Front end its showing buttons.
2) In the same form TaxInformation also not updating.
For your reference see below screens.
Through code created Transfer Order.
From front end Created Transfer Order.
I started debugging for the solution.
This is because of when we creating transfer order missed some reference tables.
So later I added that piece of code, now its working fine as per my expectation.
Code
inventTransferLine_IN.InventTransferLine = inventTransferLine.RecId;
inventTransferLine_IN.FromTaxInformation = TaxInformation_IN::findDefaultbyLocation(inventTransferTable.fromLocation()).RecId;
inventTransferLine_IN.insert();
I hope it will useful simebody.
Happy DAXing....
I find out some useful code and try to use that code. It's working fine means i am able to create transfer order.
see below code for your reference.
Code
static void Job11(Args _args)
{
InventTransferTable inventTransferTable;
InventTransferLine inventTransferLine;
NumberSequenceReference numberSequenceReference;
NumberSeq numberSeq;
ProdBOM prodBOM;
InventTable inventTable;
;
ttsBegin;
inventTransferTable.clear();
inventTransferTable.initValue();
inventTransferTable.TransferId = "000021";
inventTransferTable.InventLocationIdFrom = "32";
inventTransferTable.modifiedField(fieldNum(InventTransferTable,InventLocationIdFrom));
inventTransferTable.InventLocationIdTo = "11";
inventTransferTable.modifiedField(fieldNum(InventTransferTable,InventLocationIdTo));
inventTransferTable.TransferStatus = InventTransferStatus::Created;
inventTransferTable.initFromAddress();
inventTransferTable.initValue();
inventTransferTable.initToAddress();
inventTransferTable.insert();
if(inventTransferTable)
{
inventTransferLine.clear();
inventTransferLine.initFromInventTransferTable(inventTransferTable,
NoYes::Yes);
inventTransferLine.ItemId = "A0001";
inventTable = InventTable::find(InventTransferLine.ItemId);
inventTransferLine.initFromInventTable(InventTable);
inventTransferLine.initFromInventTable(InventTable::find("A0001"));
inventTransferLine.initFromInventTransferTable(inventTransferTable,false);
inventTransferLine.QtyTransfer = 2;
inventTransferLine.QtyShipNow = 0;
inventTransferLine.QtyReceiveNow = 0;
inventTransferLine.QtyRemainShip = 1;
inventTransferLine.QtyRemainReceive = 1;
inventTransferLine.insert(NoYes::Yes);
}
ttsCommit;
}
Successfully created but I find out some issues like
1) when I am try to posting, posting buttons disabled. But when I try to create transfer order from
Front end its showing buttons.
2) In the same form TaxInformation also not updating.
For your reference see below screens.
Through code created Transfer Order.
From front end Created Transfer Order.
I started debugging for the solution.
This is because of when we creating transfer order missed some reference tables.
So later I added that piece of code, now its working fine as per my expectation.
Code
inventTransferLine_IN.InventTransferLine = inventTransferLine.RecId;
inventTransferLine_IN.FromTaxInformation = TaxInformation_IN::findDefaultbyLocation(inventTransferTable.fromLocation()).RecId;
inventTransferLine_IN.insert();
I hope it will useful simebody.
Happy DAXing....
4 Mar 2016
Enable/Disable controls in List Page + AX 2012
My requirement like when my purchase order Status = Openorder i don't want new purchase
order Button.
order Button.
Solution::
- in the AOT, expand Forms and find the form for the list page where the action pane button appears.
Use theInteractionClass property of the form to get the name of the interaction
class for the list page. - Expand Designs, expand Design, and then expand the Action Pane. Get the name of each
action pane button that you want to enable or disable based on the list selection. - Expand Classes, right-click the interaction class for the list page, click Override Method, and
then clickselectionChanged. The Editor window opens and displays the selectionChanged method. - Check that Control which you want to Enable or Disable has property AutoDeclaration is set to Yes.
Write code like this before Super()
this.listPage().actionPaneControlEnabled(formControlStr(PurchTableListPage,NewPurchOrder),false);
else
this.listPage().actionPaneControlEnabled(formControlStr(PurchTableListPage,NewPurchOrder),true);
1 Mar 2016
Retrieve Enum Value through X++ in AX 2012
static void EnumValue(Args _args)
{
DictEnum dictEnum;
int i;
dictEnum=new DictEnum(enumName2Id("Gender"));
for(i=0;i<dictEnum.values();i++)
{
info(strFmt("Enum Label:: %1 ",dictEnum.index2Label(i)));
info(strFmt("Enum values:: %1 ",dictEnum.index2Value(i)));
}
}
{
DictEnum dictEnum;
int i;
dictEnum=new DictEnum(enumName2Id("Gender"));
for(i=0;i<dictEnum.values();i++)
{
info(strFmt("Enum Label:: %1 ",dictEnum.index2Label(i)));
info(strFmt("Enum values:: %1 ",dictEnum.index2Value(i)));
}
}
23 Feb 2016
lookup with joining two tables in AX 2012
This code in the lookup() method.
The same code can be written in three places to achieve the lookup.
1) Under AOT->Table->Method and cal this method from the form design where you want to display the lookup.
2) Form->Datasource->Table->Field->method
3) Form->Design->Field->Method.
public void lookup()
{
Query query = new Query();
QueryBuildDataSource qbds;
QueryBuildDataSource QbdsJoin;
// Instantiate sysTableLookup object using table which will provide the visible fields
SysTableLookup sysTableLookup = sysTableLookup::newParameters(tableNum(TableName), this);
;
// Create the query.
qbds= query.addDataSource(tableNum(TableName));
qbds.addRange(fieldNum(TableName, FieldName)).value('Value');
//Join Table
QbdsJoin= qbds.addDataSource(tableNum(TableName2));
QbdsJoin.relations(true);
QbdsJoin.joinMode(JoinMode::ExistsJoin);
QbdsJoin.addRange(fieldNum(TableName2, Fieldname)).value('Value');
// Set the query to be used by the lookup form
sysTableLookup.parmQuery(query);
// Specify the fields to show in the form.
sysTableLookup.addLookupfield(fieldNum(TableName, FiledName));
sysTableLookup.addLookupfield(fieldId2Ext(fieldNum(TableName, Dimension), 1));
// Perform the lookup
sysTableLookup.performFormLookup();
}
16 Feb 2016
Run a form automatically when opening dynamics AX + 2012
Create a new menu item for the form which form you want run opening dynamics AX.
Call that method as shown in below
new MenuFunction(menuitemDisplayStr(YourMenuItemName), MenuItemType::Display).run();
Place this code to Info.startupPost() (if you want it to start when the client starts)
or
Info.workspaceWindowCreated() (if you want it to start every time new workspace is opened).
new MenuFunction(menuitemDisplayStr(YourMenuItemName), MenuItemType::Display).run();
Place this code to Info.startupPost() (if you want it to start when the client starts)
or
Info.workspaceWindowCreated() (if you want it to start every time new workspace is opened).
or
Info.workspaceWindowCreated() (if you want it to start every time new workspace is opened).
3 Feb 2016
Create a link in info log to maintable + AX 2012
Today I come across a user requirement , that user need a link on info log for go to main table.
static void Axaptaexplorerinfo(Args _args)
{
CustAccount custAccount = "C00001";
CustTable custTable;
args args = new args();
SysInfoAction_FormRun infoAction = SysInfoAction_FormRun::newFormName(formStr(CustTable));
;
custTable = CustTable::find(CustAccount);
args.record(CustTable );
info(strFmt("Custaccount id %1",CustTable.AccountNum),"",SysInfoAction_TableField::newBuffer(CustTable));
}
4 Jan 2016
Finding Formdatasources through X++ in AX 2012
static void LegenderFormDataSourcesFind(Args _args)
{
FormRun formRun;
FormBuildDataSource formBuildDataSource;
int i;
Args args = new Args();
args.name("SalesTable");
formRun = ClassFactory.formRunClass(args);
for(i=1 ; i<=formRun.form().dataSourceCount();i++)
{
formBuildDataSource = formRun.form().dataSource(i);
info(new DictTable(formBuildDataSource.table()).name());
}
}
{
FormRun formRun;
FormBuildDataSource formBuildDataSource;
int i;
Args args = new Args();
args.name("SalesTable");
formRun = ClassFactory.formRunClass(args);
for(i=1 ; i<=formRun.form().dataSourceCount();i++)
{
formBuildDataSource = formRun.form().dataSource(i);
info(new DictTable(formBuildDataSource.table()).name());
}
}
Subscribe to:
Posts (Atom)
Create number sequence in D365 FO
Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...
-
Dialogbutton dialogButtonConfirm; ; dialogButtonConfirm = Box::yesNo("continue ", dialogButton::Yes, ...
-
Breakpoints Command Shortcut key Remove all breakpoints. CTRL+SHIFT+F9 I...
-
Just use the below code to remove the special character from the string. strRem('String','*'); You can replace * with...