コミュニティ

Create new iteration of repeating group in c# script rule

Hi All,

I have a repeating group called 'NominalCoding' that has fields 'NominalAccount', 'CostCentre', 'Department' and 'Net'

I also have a script that creates a dataset which includes the data to fill out each iteration of 'NominalCoding' repeating group.

How do I create a new iteration of the repeating group 'NominalCoding' and get the current instance number to be able to use to fill data into 'NominalAccount', 'CostCentre', 'Department' and 'Net' from the dataset?

Code I'm using to get the data


using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient
using System.Windows.Forms;
using System.Data.Odbc;
using System.Xml;

string varPONumber = Context.Field("OrderNumber").Text;
string SEL_COM = "Select NominalAccountRef, NominalCostCentre, NominalDepartment, LineTotalValue from vw_flexicapture_orderlinelist where PONumber =" + "\'" + varPONumber + "\'";
string CON_STRING = "Server=*****;Database=****;Uid=*****;Pwd=*****;";

//create list to house companies
List listnominalAccount = new List();
List listcostCentre = new List();
List listdepartment = new List();
List listnet = new List();


//connect to sql to parse all possible companies user has access to
SqlDataAdapter sqlAdapter = null;
sqlAdapter = new SqlDataAdapter(SEL_COM, CON_STRING);
DataSet nominals = new DataSet();
sqlAdapter.Fill(nominals, "Nominals");
foreach (DataTable table in nominals.Tables)
{
foreach (DataRow row in table.Rows)
{
string varNominalAccount = row["NominalAccountRef"].ToString();
varNominalAccount = varNominalAccount.Trim();
listnominalAccount.Add(varNominalAccount);

string varCostCentre = row["NominalCostCentre"].ToString();
varCostCentre = varCostCentre.Trim();
listcostCentre.Add(varCostCentre);

string varDepartment = row["NominalDepartment"].ToString();
varDepartment = varDepartment.Trim();
listdepartment.Add(varDepartment);

string varNet = row["LineTotalValue"].ToString();
varNet = varNet.Trim();
listnet.Add(varNet);
}
}



Many thanks

Richard

この記事は役に立ちましたか?

0人中0人がこの記事が役に立ったと言っています

コメント

3件のコメント

  • Avatar
    Permanently deleted user

    using System.Collections.Generic;
    using System.Data;
    using System.Data.SqlClient
    using System.Windows.Forms;
    using System.Data.Odbc;
    using System.Xml;

    string varPONumber = Context.Field("OrderNumber").Text;
    string SEL_COM = "Select NominalAccountRef, NominalCostCentre, NominalDepartment, LineTotalValue from vw_flexicapture_orderlinelist where PONumber =" + "\'" + varPONumber + "\'";
    string CON_STRING = "Server=****;Database=****;Uid=****;Pwd=****;";

    //create list to house companies
    List listnominalAccount = new List();
    List listcostCentre = new List();
    List listdepartment = new List();
    List listnet = new List();

    //connect to sql to parse all possible companies user has access to
    SqlDataAdapter sqlAdapter = null;
    sqlAdapter = new SqlDataAdapter(SEL_COM, CON_STRING);
    DataSet nominals = new DataSet();
    sqlAdapter.Fill(nominals, "Nominals");
    foreach (DataTable table in nominals.Tables)
    {
    int numNoms = 0;
    foreach (DataRow row in table.Rows)
    {
    Context.Field("NominalCoding").Items.AddNew(1);
    string varNominalAccount = row["NominalAccountRef"].ToString();
    varNominalAccount = varNominalAccount.Trim();
    listnominalAccount.Add(varNominalAccount);
    Context.Field("NominalAccount").Items[numNoms].Text = varNominalAccount;

    string varCostCentre = row["NominalCostCentre"].ToString();
    varCostCentre = varCostCentre.Trim();
    listcostCentre.Add(varCostCentre);
    Context.Field("CostCentre").Items[numNoms].Text = varCostCentre;

    string varDepartment = row["NominalDepartment"].ToString();
    varDepartment = varDepartment.Trim();
    listdepartment.Add(varDepartment);
    Context.Field("Department").Items[numNoms].Text = varDepartment;

    string varNet = row["LineTotalValue"].ToString();
    varNet = varNet.Trim();
    listnet.Add(varNet);
    Context.Field("Net").Items[numNoms].Text = varNet;

    numNoms = numNoms + 1;
    }
    }


    Trying to use


    Context.Field("NominalCoding").Items.AddNew(1);


    But getting error:

    AddNominalCoding:System.NotImplementedException
    0
  • Avatar
    Permanently deleted user
    And tried batch processing script:


    for ( int i = 0; i < documents.count;="" i++="">
    {

    Documents.Field("NominalCoding").Items.AddNew(0);
    Documents.Field("NominalCoding\\NominalAccount").Items.AddNew(0);

    }


    But no new instances added
    0
  • Avatar
    Permanently deleted user
    Finally got a document processing script to work with following code:

    //This is a field from the document which contains the number of nominal returned for a PONumber
    string numNet = Document.Field("Invoice Layout\\NumNoms").Text;
    //Convert string to int
    int numNetNum = int.Parse(numNet);

    //Add the nominal coding sections in
    for (int i = 1; i < numnetnum;="">
    {
    Document.Field("Invoice Layout\\NominalCoding").Items.AddNew(0);
    }



    Put it the workflow after the recognition stage and before the verification stage.
    0

サインインしてコメントを残してください。