Hi all,
I need some guidance or sample scripts if possible on the following scenario.. been cracking my heads for the past 2 days but i still cant get it right.
I need to create/edit the dimension set entry for sales order via my web services. However, it kept prompting me the following error "Specify a filter for the Dimension Set ID field in the Dimension Set Entry Table", even though i had passed in the filters into service.
This is a sample of my script. The moment it hit the "DimensionSetValue.DimensionSetValue[] s = service.ReadMultiple(fil, null, 0);". It will throe me the above error.
Appreciate your help in advance.
private int addDimension(string SourceOfOrder, string Branch, string ServiceType, int dimensionSetID)
{
string baseURL = System.Configuration.ConfigurationManager.AppSettings["wsUrl"];
string inst = System.Configuration.ConfigurationManager.AppSettings["WSInst"];
string comp = System.Configuration.ConfigurationManager.AppSettings["Company"];
string uid = System.Configuration.ConfigurationManager.AppSettings["adUserId"];
string upwd = System.Configuration.ConfigurationManager.AppSettings["adUserPwd"];
string uDomain = System.Configuration.ConfigurationManager.AppSettings["adDomain"];
var service = new DimensionSetValue_Service();
service.UseDefaultCredentials = false;
service.Url = baseURL + inst + "/WS/" + comp + "/Page/DimensionSetValue";
service.Credentials = new System.Net.NetworkCredential(uid, upwd, uDomain);
DimensionSetValue_Filter filter1 = new DimensionSetValue_Filter();
filter1.Field = DimensionSetValue_Fields.Dimension_Set_ID;
filter1.Criteria = "3";
DimensionSetValue_Filter filter2 = new DimensionSetValue_Filter();
filter2.Field = DimensionSetValue_Fields.Dimension_Code;
filter2.Criteria = "SOURCE";
//DimensionSetValue_Filter[] fil = new DimensionSetValue_Filter[] { filter1,filter2 };
DimensionSetValue_Filter[] fil = new DimensionSetValue_Filter[] { filter1 };
DimensionSetValue.DimensionSetValue[] s = service.ReadMultiple(fil, null, 0);
//DimensionSetValue.DimensionSetValue[] s = service.ReadMultiple(null, null, 0);
// Create the Dimension
//var newDimension = s[0].DimensionValueCode = SourceOfOrder;
var newDimension = new DimensionSetValue.DimensionSetValue();
//service.(ref newDimension);
//newDimension = service.Read(dimensionSetID,"'SOURCE'");
//string a = service.GetRecIdFromKey(dimensionSetID.ToString());
//newDimension.Key = dimensionSetID.ToString();
newDimension.Dimension_Set_ID = dimensionSetID;
newDimension.Dimension_Code = "SOURCE"; // SourceOfOrder;
newDimension.Dimension_Set_IDSpecified = true;
newDimension.DimensionValueCode = "EMAIL";
service.Update(ref newDimension);
return newDimension.Dimension_Set_ID;
}
TIA
Penelope
0
Comments
The Way you have assigned the filter is wrong
This Statment below should be before you declared te other filters
DimensionSetValue_Filter[] fil = new DimensionSetValue_Filter[] { filter1 };
And this statement should look like this
DimensionSetValue_Filter[] fil = new DimensionSetValue_Filter[];
Then After Filter1.Criteria := '3'; you have write
Fil = filter1
Similarly after filter2.Criteria also.
Then you have to write the Readmultiple statement.
Hope this helps.