Enterprise Portal Development Videos

Enterprise Portal Development Series: 

http://msdn.microsoft.com/en-us/dynamics/ax/cc507280.aspx

Videos at CustomerSource

Reference : http://dotnetxperience.blogspot.fi/

Passing parameters from Modal dialog to calling page.

 Caller page:

    protected void Page_Load(object sender, EventArgs e)
{

AxBaseWebPart.GetWebpart(this).ModalDialogClosed += new EventHandler(Base_ModalDialogClosed);
}

///
/// This method will  be used to Returning the value ModalDialogClosed.
///
///
///
void Base_ModalDialogClosed(object sender, AXModalDialogClosedEventArgs e)
{
// Code to handle the returned value.
string returnValue;
returnValue = e.DialogArgs.Data;
QtyEdit.Text = returnValue;
try
{
if (returnValue != String.Empty && localRecId != String.Empty)
{
this.OrderListDS.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call(“PurchLine”, returnValue, localRecId);
}
}
catch (Exception ex)
{
Proxy.Info objInfoLog = new Proxy.Info(this.AxSession.AxaptaAdapter);
objInfoLog.add(Proxy.Exception.Info, “Ordering list not selected”);
}
}

Modal Page :

On button click:
protected void SaveButton_Click(object sender, EventArgs e)
{
AXDialogArgs args = DialogHelper.DialogArgs;
args.Data = QtyEdit.Text;
DialogHelper.Close(CloseDialogBehavior.Auto);
//can use the below to refresh calling page.
//DialogHelper.Close(CloseDialogBehavior.RefreshPage);

}

Filter Invent On -Hand based on WMSLocation

Today I have faced a issue how to show or filter data on InventSum Grid in EP from WMSLocation i.e. for each location there should be Invent On-hand data.

Same as AX 2012 R3 rich client in EP.

For these following are the steps:

  1. Create a Dataset EPInventGridOnHand.
  2. Add InventSum and InventDim table in datasource of EPInventGridOnHand dataset.
  3. Now on init() method of EPInventGridOnHand dataset we will get WMSLocation buffer with InventLocationId and WmsLocationId field value and write below code before dataset Init method super()

switch(element.args().dataset())

{
case(tableNum(WMSLocation)):
wmsLocation = element.args().record(); // Here wmsLocation is a global table buffer
break;
}

For filtering based on WMSLocation write below code after dataset init method super()

               //Filter Invent On-hand based on WMSlocation

inventDim_ds.query().dataSourceTable(tableNum(InventDim)).addRange(fieldnum(InventDim,wmsLocationId)) .                                   value(queryValue(wmsLocation.wMSLocationId));

inventDim_ds.query().dataSourceTable(tableNum(InventDim)).addRange(fieldnum(InventDim,InventLocationId)) .                                 value(queryValue(wmsLocation.inventLocationId));

              //This will group by Onhand based on Item

inventSum_ds.query().dataSourceTable(tableNum(Inventsum)).addGroupByField(fieldNum(Inventsum, ItemId));

             //This will add fields in InventSum run time with clubbing the values.
InventSum::queryAddSumFields(inventSum_DS.query().dataSourceTable(tableNum(InventSum)));

Thanks

Arun Garg

Custom lookup on EP

To provide an ASP.Net text box to work as AX lookup field, need to follow following steps
1-Creae a new text box in page (Out of AXForm)
2-Add new ax lookup control from tool box
3-Set target control as added text box by using Lookup control’s target properly
4-If you want to show filtered data on the lookup then chose lookup types as CustomDataSet
5-To define lookup dataset use lookupControl’s Lookup event and set lookupDataSet by using following pattern code

protected void LookupFieldName_Lookup(object sender, AxLookupEventArgs e)
{
//Getcurrent user to filter record based on current user
String usr = WindowsIdentity.GetCurrent().Name;
int pos = usr.IndexOf(‘\\’);
usr = pos != -1 ? usr.Substring(pos + 1) : usr;
AxLookup lookup = (AxLookup)sender;

// Create the lookup data set. The respective table will be used.
Proxy.SysDataSetBuilder sysDataSetBuilder;
sysDataSetBuilder = Proxy.SysDataSetBuilder.constructLookupDataSet(AxSession.AxaptaAdapter,TableMetadata.TableNum(AxSession, “TableName”));

// Set the generated data set as the lookup data set.
lookup.LookupDataSet = new DataSet(AxSession, sysDataSetBuilder.toDataSet());
using (Proxy.Query query = lookup.LookupDataSet.DataSetViews[0].MasterDataSource.query())
{
query.dataSourceNo(1).addRange(TableArrayFieldMetadata.FieldNum(this.AxSession, “TableName”, “FieldName”)).value = “ValueInStringFormat”
//Example String.Format(“{0:dd/MM/yyyy}..{1}”, System.DateTime.Today, DateTime.MaxValue.ToShortDateString());

}

// Specify the fields for the lookup.
lookup.Fields.Add(AxBoundFieldFactory.Create(AxSession, lookup.LookupDataSetViewMetadata.ViewFields[“Field1”]));
lookup.Fields.Add(AxBoundFieldFactory.Create(AxSession, lookup.LookupDataSetViewMetadata.ViewFields[“Field2”]));
lookup.Fields.Add(AxBoundFieldFactory.Create(AxSession, lookup.LookupDataSetViewMetadata.ViewFields[“Field3”]));
lookup.Fields.Add(AxBoundFieldFactory.Create(AxSession, lookup.LookupDataSetViewMetadata.ViewFields[“Field4”]));
// Specify the select field for the lookup.
lookup.SelectField = “Index/LookupFieldName”;

Upload document through EP in AX

To provide document attachement feature on EP form to upload documents, need to follow below setps 

1-Add new datasource by using EPDocuInfoAdd data set from AX
2-Add new ASP:FileUpload control on page
3-On Ok/Submit button call below method after Inserting/Updating recordprivate void DocumentUpload()
{
DataSetView datasetViewAppl = DataSourceName.GetDataSourceView(AXFormControlName.DataMember).DataSetView;

DataSetViewRow docuRefAdd = this.dsDocuRef.GetDataSourceView(“DocuRef”).DataSetView.AddNew();
DataSetViewRow docuRefCurrent = this.dsDocuRef.GetDataSourceView(“DocuRef”).DataSetView.GetCurrent();

IAxaptaRecordAdapter docuRefRecord = docuRefCurrent.GetRecord();
docuRefRecord.SetField(“RefTableId”, (object)datasetViewAppl.GetCurrent().GetFieldValue(“TableId”));
docuRefRecord.SetField(“RefRecId”, (object)datasetViewAppl.GetCurrent().GetFieldValue(“RecId”));
docuRefRecord.SetField(“TypeId”, “File”);

string[] myFiles = Request.Files.AllKeys;
bool dataSaved = false;
if (FileUpload1.HasFile)
{
using (IAxaptaRecordAdapter irecDocuValue = ApplicationProxy.EPDocumentHandling.saveWebDocumentClient(
AxSession.AxaptaAdapter,
docuRefRecord,
Request.Files.AllKeys[0]))
{
{
if (irecDocuValue != null)
{
// Get the RecId of the insert DocuValue record.
Int64 valueRecId = (Int64)irecDocuValue.GetField(“RecId”);

if (valueRecId != 0)
{
//Update the ValueRecId field of the DocuRef record with the RecId of the DocuValue record
docuRefRecord.SetField(“ValueRecId”, (object)valueRecId);

// Saves the DocuRef record in the DB.
ApplicationProxy.EP.createDocuRef(AxSession.AxaptaAdapter, docuRefRecord);

// Set this parameter to enable redirection.
dataSaved = true;
}
else
throw new System.Exception(“File upload error”);
}
}
}

Enterprise Portal Installation: Error during retrieval of List of Sites

Enterprise Portal Installation: Error during retrieval of List of Sites
The log file contains…

Entering function Microsoft.Dynamics.Framework.Deployment.Portal.IEPDeployment.GetVirtualServerList
Entering method GetNamesOfAllWebSites
Leaving method GetNamesOfAllWebSites
The return value from this method is ‘1,2,3,4,5,288200494,1434903486’.
Entering method GetWebSite
The input parameters to this method are: ‘1’
Leaving method GetWebSite
The return value from this method is ‘1’.
Entering method GetFriendlyNameOfWebSite
The input parameters to this method are: ‘1’
Entering method GetWebSite
The input parameters to this method are: ‘1’
Leaving method GetWebSite
The return value from this method is ‘1’.
Leaving method GetFriendlyNameOfWebSite
The return value from this method is ‘Default Web Site’.
Entering method GetPortNumberOfWebSite
The input parameters to this method are: ‘1’
Entering method GetWebSite
The input parameters to this method are: ‘1’
Leaving method GetWebSite
The return value from this method is ‘1’.
Exception: System.InvalidOperationException

Message: Operation is not valid due to the current state of the object.

FullText: System.InvalidOperationException: Operation is not valid due to the current state of the object.
at Microsoft.Dynamics.Framework.Deployment.Web.WebSiteConfigurator.GetServerBindingsInformation(String webSiteName, ServerBindings serverBinding)
at Microsoft.Dynamics.Framework.Deployment.Web.WebSiteConfigurator.GetPortNumberOfWebSite(String webSiteName)
at Microsoft.Dynamics.Framework.Deployment.Portal.EPDeployment.get_IISVirtualServers()
at Microsoft.Dynamics.Framework.Deployment.Portal.EPDeployment.GetVirtualServerList()
at Microsoft.Dynamics.Framework.Deployment.Portal.EPDeployment.Microsoft.Dynamics.Framework.Deployment.Portal.IEPDeployment.GetVirtualServerList()
at Microsoft.Dynamics.Setup.DeploymentPortalWrapper.GetVirtualServerList()
at Microsoft.Dynamics.Setup.MainForm.s300_ShowTab(Object sender, EventArgs e)
at Microsoft.Dynamics.Setup.AxTabPage.ShowPage()
at Microsoft.Dynamics.Setup.MainForm.ShowPage(PageIDs pageID)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

==== Setup encountered an unhandled exception and could not be completed. For details see the previous messages in the log. ===

Solution: Check the .NET Bussiness Connector Permissions. Resolved…

Enterprise Portal: Lookup not works in Enterprise portal

If user clicks on lookups then lookup form will display but the selected value will not reflect in to the text box.

Solution: Disable IE ESC for the users
1. Open the Server Manager Tool. Configure IE ESC is located on the right hand side of the interface in the section heading Security Information.
2. Select the link Configure IE Esc and the configuration window will open. At this point you can choose whether to turn off IE ESC for Administrators or for Users or for both.

Excel download and open error from portal

Once we download excel file from portal and try to open file the below error will be shown.

The code used for the download is as follows.
HttpContext.Current.Response.TransmitFile(filepath);
System.IO.File.Delete(filepath);
HttpContext.Current.Response.End();

Here the issue comes because the file will be deleted immediately once the file transmitted. During this time the original file will be locked by other process.

So changing the code as below will resolves the issue.

HttpContext.Current.Response.TransmitFile(filepath);
HttpContext.Current.Response.Flush();
System.IO.File.Delete(filepath);
HttpContext.Current.Response.End();