I just tried this and got a different error. Can someone please help me with this? The red is where the error is occurring and the blue text is new code. The salesorderdetailid value is {00000000-0000-0000-0000-000000000000}. I used the debugger to see this. Code: QueryExpression qrySOD = new QueryExpression("salesorderdetail"); string[] cols2 = { "salesorderdetailid", "productid" }; qrySOD.Criteria = new FilterExpression(); qrySOD.Criteria.AddCondition("productid", ConditionOperator.Equal, GetGuidByFirstNamel(r.ProductName)); qrySOD.ColumnSet = new ColumnSet(cols2); var sod = _service.RetrieveMultiple(qrySOD); //Casting the reference to GUID Guid salesorderdetailid = (Guid)sod[0].Id; private Guid GetGuidByFirstNamel(String pname) { QueryExpression query = new QueryExpression { EntityName = "product", ColumnSet = new ColumnSet("productid"), Criteria = new FilterExpression { Filters = { new FilterExpression { Conditions = { new ConditionExpression { AttributeName = "product", Operator = ConditionOperator.Equal, Values = { "productid" } } } } } }}; return Guid.Empty; }
↧