Wednesday, January 9, 2019

Get the value of the Line item custom column fields in C# .NET application

Sample C# Code:
foreach (SalesOrderItem soItemLine in mySO.itemList.item){                    Console.WriteLine("line: " + soItemLine.line + "\n" +			   "item: " + soItemLine.item.name + "\n" +			   "amount: " + soItemLine.amount + "\n" +			   "quantity: " + soItemLine.quantity + "\n");      //Process custom column fields   CustomFieldRef[] cfr = soItemLine.customFieldList;	for (int i = 0; i < cfr.Length; i++)	{	//Check for the custom column field type	if (cfr[i].GetType() == typeof(BooleanCustomFieldRef))	{		//Cast the type to the value and get access to internal id and value property		BooleanCustomFieldRef myval = (BooleanCustomFieldRef)cfr[i];		Console.WriteLine(myval.value);	}	else if (cfr[i].GetType() == typeof(StringCustomFieldRef))	{		StringCustomFieldRef myString = (StringCustomFieldRef)cfr[i];		Console.WriteLine(myString.value);	}	//continue with other data type.....	}}

No comments:

Post a Comment