Dynamics Ax 2012: How to implement an edit method and use it within Enterprise Portal
Overview
I want to assign specific colors to our customers. The color will help our sales representatives determine what industries they are in. We need to create an associated Colors table which contains the Accountnum and Color fields. We want to give the data entry personnel the ability to add/edit this field from within Enterprise Portal. We would like to do this using an edit method.
I have attached the word document for download.
Create the Colors table
- Within the AOT, navigate to Data Dictionary->Tables.
- Right-click the Tables element and select “New Table”.
- In the Name attribute, enter Colors.
- Expand the Colors table so you see its child nodes. (Fields, Field Groups, etc.)
- Open a new AOT window and navigate to Data Dictionary->Extended Data Types
- Locate the “AccountNum” Extended Data Type and drag it to the Fields node of the Colors table.
- Locate the “Color” Extended Data Type and drag it to the Fields node of the Colors table.
- Right-click the Indexes element under the Colors table and select “New Index”.
- Enter “AccountNum_Idx” for the Name attribute.
- Enter “No” for the AllowDuplicates attribute.
- Right-click the “AccountNum_Idx” and select “New Field”.
- In the DataField attribute select AccountNum.
- Right-click the Methods element and select “New Method”.
- Copy the following code into the new method.
10. Save the Colors table.
Your table layout should look similar to the image below:
Create the Edit Method on the CustTable
- Within the AOT, navigate to Data Dictionary->Tables->CustTable.
- Expand the CustTable table so you see its child nodes. (Fields, Field Groups, etc.)
- Right-click the Methods element and select “New Method”.
- Copy the following code into the new method.
4. Save the CustTable table.
Restore the CustomerDetail dataset.
- Within the AOT, navigate to Data Sets->CustomerDetail.
- Right-click the CustomerDetail dataset and select Restore.
Complete the incremental compile
- From the file menu select Build->Generate Incremental CIL.
Refresh the cache
- From the file menu select Tools->Caches->Refresh dictionary.
- From the file menu select Tools->Caches->Refresh data.
- From the file menu select Tools->Caches->Refresh elements.
Update the CustomerAddEdit user control
- Open Visual Studio 2010.
- From the file menu select View->Application Explorer.
- Within the Application Explorer navigate to Web->Web Files->Web Controls->CustomerAddEdit.
- Right-click the CustomerAddEdit user control and select “Edit”.
- The CustomerAddEdit.ascx file should open up in source view. Click “Design” tab at the bottom of the window.
- Locate the AxDataSource – CustomerDS element and select it.
- Click the arrow to open the AxDataSource Tasks.
- Click the Refresh Schema link.
- Locate the AxGroup – Administration element and select it.
- Click the arrow to open the AxGroup Tasks.
- Click the Edit Fields link.
- From the Bound Field Designer – Dataset View: CustTable window locate “editCustomerColor**” within the Available Fields frame.
- Click “Add Field” button.
- Highlight “editCustomerColor**” in the Selected Field frame and under BoundField Properties set the HeaderText to “Customer Color”
- Click OK.
- Save all items.
- Close Visual Studio. (If it asks you to save the item to the AOT, select yes.)
Deploy the user control
- Within the AOT, navigate to Web->Web Files->Web Controls->CustomerAddEdit.
- Right-click the CustomerAddEdit control and select “Deploy Element”.
Test the user control
- Open Enterprise Portal and from the left hand navigation refresh the AOD, Dictionary, and Data to ensure we are looking at the latest data.
- Navigate to the Sales site by selecting the Sales tab at the top of the web page.
- From the customer list, highlight a customer and select “Edit” from the action menu.
- Minimize the “General” tab.
- Expand the “Details” tab.
- Under the Administration group you should see the Customer Color field.
- Enter a color 9 character long or less. (Red, Green, etc).
- Click Save & Close from the Action Menu.
- You can then verify that a record was created using the table browser within the AOT.