Month: May 2014

Passing selected records in Grid EP page to AX

Hi,

Below sample code allow us to send multiple selected records in Grid form EP portal page to Ax method and insert as separate records in table. 

Code in C# page :

long recId;
List<string> recIdList = new List<string>();
DataSetView purchReqLineView = this.AxDataSource2.GetDataSourceView(AxGridView1.DataMember).DataSetView; //Grid
int j = 0;
foreach (int markedRow in AxGridView1.GetMarkedRowIndexes())
{
purchReqLineView.SetCurrent(markedRow);
recId = (long)purchReqLineView.GetCurrent().GetFieldValue(“RecId”);
recIdList.Add(recId.ToString());

if (j == 0)
{
TextBox1.Text += recId;
j++;
}
else
{
TextBox1.Text += “,” + recId;
}
}

ApplicationProxy.EXDCaseServiceScheduling serviceShedul = new ApplicationProxy.EXDCaseServiceScheduling();

serviceShedul.addVendorSelection(this.TextBox1.Text); //passing to Ax class by using proxy

serviceShedul.run();

 

Below Ax code will get the TextBox1 values as string parameter and will insert into table

public void addVendorSelection(Str1260 _vendorRecIdString)
{
VendorAssignment vendorAssignment;
VendTable vendTable;
container packedList;
int i;

packedList = str2con(_vendorRecIdString);
ttsbegin;

for (i=1; i <= conLen(packedList); i++)
{
vendTable = VendTable::findRecId(conPeek(packedList,i));
vendorAssignment.clear();
vendorAssignment.VendAccount = vendTable.AccountNum;
vendorAssignment.OneTimeVendor = vendTable.OneTimeVendor;
vendorAssignment.insert();
}
ttsCommit;

 

🙂
}