Scenario: I have came across the scenario i.e. if the user send an email through batch process , need to show the hyperlink for accessing their shared folder for updating the information for respective document.
PavanKumar Idupulapati's Blog on Microsoft Dynamics Axapta
This blog is all about Microsoft Dynamics AX(formerly known as Axapta). This site contains some Microsoft Dynamics AX X++ Codes for use in your day to day use.
Tuesday, April 5, 2016
Monday, April 13, 2015
Transaction Log - AX 2012 - Cannot create a record in Audit
trail (TransactionLog)
I have resolved the same issue in AX 2012,
To over come this issue, please find the below code
modifications in Tables-->TransactionLog-->Methods-->create.
The existing Code:
if (appl.lastTransactionIdCreated() !=
appl.curTransactionId())
{
transactionLog.Type = _type;
transactionLog.Txt = _txt;
transactionLog.insert();
appl.lastTransactionIdCreated(transactionLog.CreatedTransactionId);
appl.transactionlogUpdateTTSControl().revoke();
}
The changes to
make:
if (appl.lastTransactionIdCreated() !=
appl.curTransactionId())
{
if (!TransactionLog::find(appl.curTransactionId()))
{
transactionLog.Type = _type;
transactionLog.Txt = _txt;
transactionLog.insert();
appl.lastTransactionIdCreated(transactionLog.CreatedTransactionId);
}
appl.transactionlogUpdateTTSControl().revoke();
}
Regards
Pavan
Tuesday, February 3, 2015
X++ code to create a customized lookup on form
Override the lookup method on Formdatasource field(on which you want to show lookup) , and copy the following code to your method.
Comment the super() method in the lookup.
public void lookup(FormControl _formControl, str _filterStr)
{
SysTableLookup sysTableLookup; // systemclass to create //customlookup
Query query;
QueryBuildDataSource qbd;
;
sysTableLookup = SysTableLookup::newParameters(tablenum(InventTable),_formcontrol);
// Construct query on the table,
// whose records you want to show as lookup.
query = new Query();
qbd = query.addDataSource(tablenum(InventTable));
qbd.addRange(fieldnum(InventTable,ItemType)).value(SysQuery::value(enum2str
(ItemType::Item)));
// add the fields to the lookup list
sysTableLookup.addLookupfield(fieldnum(InventTable,ItemId));
sysTableLookup.addLookupfield(fieldnum(InventTable,ItemName));
// pass the query as parameter
// system will show the records in the lookup
// as per your query
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
public void lookup(FormControl _formControl, str _filterStr)
{
SysTableLookup sysTableLookup; // systemclass to create //customlookup
Query query;
QueryBuildDataSource qbd;
;
sysTableLookup = SysTableLookup::newParameters(tablenum(InventTable),_formcontrol);
// Construct query on the table,
// whose records you want to show as lookup.
query = new Query();
qbd = query.addDataSource(tablenum(InventTable));
qbd.addRange(fieldnum(InventTable,ItemType)).value(SysQuery::value(enum2str
(ItemType::Item)));
// add the fields to the lookup list
sysTableLookup.addLookupfield(fieldnum(InventTable,ItemId));
sysTableLookup.addLookupfield(fieldnum(InventTable,ItemName));
// pass the query as parameter
// system will show the records in the lookup
// as per your query
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Building Lookups - Using a form for lookup building
In numerous situations, standard, automatic, or even dynamic runtime lookups cannot display the required data. For example, it might be a lookup with tab pages or a search field. In such cases, Dynamics AX offers the possibility to create an AOT form and use it as lookup.
In this recipe, we will demonstrate how to create a lookup using an AOT form. As an example, we will modify the standard customer account lookup to display only active customers.
How to do it...
-
-
2. Change the form's following design properties:
Property Value
Frame Border
WindowType Popup
-
-
4. Add a new StringEdit control to the grid:
Property Value
Name AccountNum
DataSource CustTable
DataField AccountNum
AutoDeclaration Yes
-
5. Add another StringEdit control to the grid, right after AccountNum:
Property Value
Name Name
DataSource CustTable
DataField Name
-
6. Add one more StringEdit control to the grid, right after Name:
Property Value
Name Phone
DataSource CustTable
DataField Phone
-
-
-
9. Override the form's run() with the following code:
public void run()
{
FormStringControl callingControl;
boolean filterLookup;
;
callingControl = SysTableLookup::getCallerStringControl(
element.args());
filterLookup = SysTableLookup::filterLookupPreRun(
callingControl,
AccountNum,
CustTable_ds);
super();
SysTableLookup::filterLookupPostRun(
filterLookup,
callingControl.text(),
AccountNum,
CustTable_ds);
}
-
10. Finally, override init() of the CustTable data source with the following code:
public void init()
{
Query query;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
;
query = new Query();
qbds = query.addDataSource(tablenum(CustTable));
qbr = qbds.addRange(fieldnum(CustTable, Blocked));
qbr.value(queryvalue(CustVendorBlocked::No));
this.query(query);
}
-
- 2. Change the form's following design properties:
Property Value Frame Border WindowType Popup
- 4. Add a new StringEdit control to the grid:
Property Value Name AccountNum DataSource CustTable DataField AccountNum AutoDeclaration Yes
- 5. Add another StringEdit control to the grid, right after AccountNum:
Property Value Name Name DataSource CustTable DataField Name
- 6. Add one more StringEdit control to the grid, right after Name:
Property Value Name Phone DataSource CustTable DataField Phone
- 9. Override the form's run() with the following code:
public void run() { FormStringControl callingControl; boolean filterLookup; ; callingControl = SysTableLookup::getCallerStringControl( element.args()); filterLookup = SysTableLookup::filterLookupPreRun( callingControl, AccountNum, CustTable_ds); super(); SysTableLookup::filterLookupPostRun( filterLookup, callingControl.text(), AccountNum, CustTable_ds); }
- 10. Finally, override init() of the CustTable data source with the following code:
public void init() { Query query; QueryBuildDataSource qbds; QueryBuildRange qbr; ; query = new Query(); qbds = query.addDataSource(tablenum(CustTable)); qbr = qbds.addRange(fieldnum(CustTable, Blocked)); qbr.value(queryvalue(CustVendorBlocked::No)); this.query(query); }
-
12. Locate the extended data type CustAccount in AOT, and change its property:
Property Value
FormHelp CustLookup
- 12. Locate the extended data type CustAccount in AOT, and change its property:
Property Value FormHelp CustLookup
The newly created CurrencyLookup form will replace the automatically generated customer account lookup. It is recommended to append text Lookup to the end of the form name, so that lookups can be easily distinguished from other AOT forms.
In order to make our form lookup looks exactly like a standard lookup, we have to adjust its layout. So, we set form design Frame and WindowType properties respectively to Border and Popup. This removes form borders and makes the form lookup like a true lookup. By setting the grid property ShowRowLabels to No, we hide grid row labels, which are also not a part of automatically generated lookups. Then, we create a grid with four controls, which are bound to the relevant CustTable table fields.
Next, we change the data source properties. We do not allow any data change by setting AllowEdit, AllowCreate, and AllowDelete properties to No. Security checks should be disabled by setting AllowCheck to No. To increase performance, we set OnlyFetchActive to Yes, which will reduce the size of the database result set to only the fields that are visible. We also set the data source index to improve lookup performance.
Now, we need to define which form control will be returned as a lookup value to the calling form upon user selection. We need to specify it manually in the form's init() by calling element.selectMode() with the name of the AccountNumcontrol as argument.
In the form's run(), we simulate standard lookup filtering, which allows user to user * symbol to search for records in the lookup. For example, if the user types 1* into the Customer account control, the lookup will open automatically with all customer accounts starting with 1. To achieve that, we use the filterLookupPreRun() and filterLookupPostRun() methods of the standard SysTableLookup class. Both methods requires calling a control, which we get by using getCallerStringControl() method of SysTableLookup. The first method reads user input and returns true if a search is being performed, otherwise, false. It must be called before the super() in the form's run() and accepts four arguments:
-
1. The calling control on the parent form.
-
2. The returning control on the lookup form.
-
3. The lookup data source.
-
4. An optional list of other lookup data sources.
The filterLookupPostRun() must be called after the super() in the form's run() and also accepts four arguments:
-
1. A result value from previously called filterLookupPreRun().
-
2. The user text specified in the calling control.
-
3. The returning control on the lookup form.
-
4. The lookup data source.
The code in the CustTable data source's init() replaces the data source query created by its super() with the custom one. Basically, here we create a new Query object, add a range to show only active customers, and set this object as the new CustTable data source query. This ensures that there are no dynamic links from the caller form's data source.
- 1. The calling control on the parent form.
- 2. The returning control on the lookup form.
- 3. The lookup data source.
- 4. An optional list of other lookup data sources.
- 1. A result value from previously called filterLookupPreRun().
- 2. The user text specified in the calling control.
- 3. The returning control on the lookup form.
- 4. The lookup data source.
Run a form automatically when opening dynamics AX
create menu item for the form and call:
new MenuFunction(menuitemDisplayStr(YourMenuItemName), MenuItemType::Display).run();
Place this code to Classes -> Info ->Methods -> startupPost() (if you want it to start when the client starts) or
Classes -> Info ->Methods -> workspaceWindowCreated() (if you want it to start every time new workspace is opened).
Classes -> Info ->Methods -> workspaceWindowCreated() (if you want it to start every time new workspace is opened).
Monday, February 17, 2014
Exchange Rate field Enable in AX 2012
HI All
In standard AX, the AP invoice journal and the general journal contain the field for currency exchange rate. However, this field by default is not editable.
Path: Accounts payable à Journals à Payment journal à Lines à General tab
by default in standard this field is non editable .
Solution : To make this field as editable
AOT-->Classes-->LedgerJournalFormTrans-->setExchRateEnabled() Method. Just comment this whole code automatically Exchange rate and Secondary exchange rate fields should get enabled.
In standard AX, the AP invoice journal and the general journal contain the field for currency exchange rate. However, this field by default is not editable.
Path: Accounts payable à Journals à Payment journal à Lines à General tab
by default in standard this field is non editable .
Solution : To make this field as editable
AOT-->Classes-->LedgerJournalFormTrans-->setExchRateEnabled() Method. Just comment this whole code automatically Exchange rate and Secondary exchange rate fields should get enabled.
Monday, February 3, 2014
AX SSRS Error: The request failed with HTTP status 401: Unauthorized.
In AX, when certain users attempt to access an SSRS report in an environment, they are getting the error 'The request failed with HTTP status 401: Unauthorized' (Figure 1 below). This was occurring for all reports for this user. Other users were able to access the report perfectly fine. The user was able to run everything perfectly the day before. The answer was Troubleshooting step 5 below: Log out of Windows instance and log back in. I'll provide the long troubleshooting steps below in case someone else's issue was different.
This issue is a permissions issue somewhere. At this point, we need to determine if its an issue with the user accessing the report. You can do the below troubleshooting steps. This was the order I did it in but you don't have to do it in this order.
- SSRS server (server permissions)
- SSRS reports (SSRS permission restrictions)
- AX security issue (probably not but good to check)
- An issue with all users or just them
- An issue with local cache or something screwy with current windows session
To help the users identify this issue, I usually ask them to do the following on the server where they are receiving this error:
- Click on the Start menu in Windows
- Type 'cmd' in the 'Search programs and files' search line in the start menu
- In the command prompt, type 'ping CDBRS-MAX01'
- Take a screenshot of the command responses and send back the results.
- The results should come back with the standard ping response of 'Reply from XX.XX.X.XXX: bytes=32...''.
Troubleshoot 2:
Having established they can access the report server, have the user access the report through the SSRS server. Have them do the following in the server where the AX client is erroring and if necessary, the SSRS report server itself:
- Go to internet explorer and access the SSRS report server (commonly 'http://[SSRSSERVERNAMEHERE]/reports'
- Once here, go to 'Dynamics AX' folder
- click on the report that is erroring
- Run the report and see if it runs. Just make sure required fields are populated.
Troubleshoot 3:
Have the user run the report from a server other than the one where the user was encountering the error. I logged into the AOS on their machine under my name and did the hold shift+right click on the .axc file, enter their credentials so we were running AX as that user in my server instance, and try running the report.
Troubleshoot 4:
Have other users attempt to run that report as well as others. Determine if its an issue with just that user. If no one is able to run the report or others, the reports may need to be deployed or the SSRS server settings need to be checked.
Troubleshoot 5:
This actually resolved the issue. Something went wrong with the user's Windows server session. I wasn't exactly sure what the issue was but having the user log out and log back in to the server resolved.
In this test, do the following:
- go to the person's terminal and watch them try to run the report
- hold shift+right click on the .axc file they were using to run the report and run as a different user. Use your own user
- In AX under your user in their terminal session, try to run the troubled report.
- If it passes (it did in my instance), hold shift+right click on the .axc file and run as a different user, only this time use the person's credentials. For us, the user was able to run the report this way but not when just clicking on the .axc in the normal fashion
Subscribe to:
Posts (Atom)