Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
Contributor
dyataco
Posts: 11
Registered: 06-13-2011
0

C# nGetValue

for some reason mu nGetValuie is returning blank, any idea?

 

public List<Ingredient> GetIngredientsFromMAS90()
{
List<Ingredient> lstIngredient = new List<Ingredient>(); //Here we create a list object of Employee type

// write the logic to retrive the ingredients from MAS90 here
// once getting data, as per the count of the ingredients downloaded from MAS90, loop throught the ingredients and construct a generic collection(i.e, list of ingredients)
//start of code
using (DispatchObject pvx = new DispatchObject("ProvideX.Script"))
{
// Replace the text "*PATH TO MAS90\HOME*" with the correct MAS90\Home path in the line below
pvx.InvokeMethod("Init", @"D:\sage\DRG_440_MD\MAS90\Home");

// Instantiate a new Session object and initialize the session
// by setting the user, company, date and module
using (DispatchObject oSS = new DispatchObject(pvx.InvokeMethod("NewObject", "SY_Session")))
{
oSS.InvokeMethod("nSetUser", "developer","");
oSS.InvokeMethod("nSetCompany", "011");
oSS.InvokeMethod("nSetDate", "C/I", DateTime.Now.ToString("yyyyMMdd"));
oSS.InvokeMethod("nSetModule", "C/I");
int TaskID = (int)oSS.InvokeMethod("nLookupTask", "CI_ItemCode_ui");
oSS.InvokeMethod("nSetProgram", TaskID);
Object xMessage ;
string xItemCode = "";
string xItemCodeDesc = "";
string xSearch = "";
int retval = 0;
string r=null, i=null;
using (DispatchObject oXX = new DispatchObject(pvx.InvokeMethod("NewObject", "CI_ItemCode_bus", oSS.GetObject())))
{
object[] getResultSetParams = new object[] { "ItemCode$", "ItemCodeDesc$", "", "", "ItemType$ ="+(char)34+"1"+(char)34, "", "" };
oXX.InvokeMethodByRef("nGetResultSets",getResultSetParams);
string [] names = getResultSetParams[2].ToString().Split(System.Convert.ToChar(352));
for (int x = 1; x < names.Length - 1; x++)
{
xSearch = names[x];
retval = (int) oXX.InvokeMethod("nFind",xSearch);
retval = (int)oXX.InvokeMethod("nGetRecord");
retval = (int) oXX.InvokeMethod("nGetValue","ItemCode$",xItemCode);
retval = (int) oXX.InvokeMethod("nGetValue", "ItemCodeDesc$", xItemCodeDesc);
System.Console.WriteLine("Name Item " + x.ToString() + " : " + xItemCode + " [" +xItemCodeDesc + "]");
}
}
}
}
System.Console.WriteLine("End");

// end of code

//fill the number of ingredients count in a variable
/*
int countIngredients=0;
for (int index = 0; index < countIngredients; index++)
{
Ingredient oIngredient = new Ingredient();
// Prepare the Ingredients data like below

// oIngredient.Id = "Ingredient Id";
// oIngredient.Name = "Ingredient Name";
// etc..,

lstIngredient.Add(oIngredient);
}
*/
return lstIngredient;
}
 

Contributor
dyataco
Posts: 11
Registered: 06-13-2011
0

Re: C# nGetValue

the line retval = (int)oXX.InvokeMethod("nGetRecord"); is //retval = (int)oXX.InvokeMethod("nGetRecord");
Moderator
Natasha
Posts: 180
Registered: 07-15-2009
0

Re: C# nGetValue

Look at the solution in this post. 

 

http://community.sagemas.com/t5/Business-Object-Interface/BOI-amp-Shipment/td-p/69243

 

Natasha Chang
Sr. Software Engineer
Sage 100 ERP
unidentified user
zbillg
Posts: 4
Registered: 03-08-2012
0

Re: C# nGetValue

Hi, Im new in development with BOI by .net (C#). Could you please tell me or share me sample code about it.

 

Follow your topic, I can't find any DispatchObject  class (reference). How can you do that? :smileysad:

unidentified user
dmkutetsky
Posts: 2
Registered: 03-16-2012
0

Re: C# nGetValue

Hi zbillg.

 

I searched this class too and I find it here:
http://community.sagemas.com/t5/Business-Object-Interface/Help-sample-code-c/td-p/72695