Hello Experts,
With the help of the valuable responses for my other posts, I was able to read the product properties et al using XrmServiceToolkit in JScript.
// JQuery to get the product details
XrmServiceToolkit.Rest.Retrieve(
pOpProdID,
"OpportunityProductSet",
"CreatedOn,OpportunityId,OpportunityProductId,ProductId,OpportunityProduct_Dynamicpropertyinstance/DynamicPropertyId,OpportunityProduct_Dynamicpropertyinstance/DynamicPropertyInstanceid,OpportunityProduct_Dynamicpropertyinstance/ValueDecimal,OpportunityProduct_Dynamicpropertyinstance/ValueDouble,OpportunityProduct_Dynamicpropertyinstance/ValueInteger,OpportunityProduct_Dynamicpropertyinstance/ValueString,opportunity_products/ProductNumber,product_opportunities/CustomerId",
'lk_opportunityproduct_modifiedonbehalfby,OpportunityProduct_Dynamicpropertyinstance,opportunity_products,product_opportunities',
function (result) {
vProjDate = result.CreatedOn;
vProjectGUID = result.OpportunityId.Id;
vProjectID = result.OpportunityId.Name;
vMasterGUID = result.OpportunityProductId;
vProductId = result.ProductId.Id;
vProductNumber = result.opportunity_products.ProductNumber;
vAccID = result.product_opportunities.CustomerId.Id;
vPropInst = result.OpportunityProduct_Dynamicpropertyinstance;
// Get the Product Properties and concatenate into a string
vDynProp = "";
intPropCount = vPropInst.results.length;
for (intC = 0; intC < intPropCount; intC++) {
vDynProp = vDynProp + vPropInst.results[intC].DynamicPropertyId.Name + "-";
if (vPropInst.results[intC].ValueInteger != null) {
vDynProp = vDynProp + vPropInst.results[intC].ValueInteger + "|";
} else if (vPropInst.results[intC].ValueDouble != null) {
vDynProp = vDynProp + vPropInst.results[intC].ValueDouble + "|";
} else if (vPropInst.results[intC].ValueDecimal != null) {
vDynProp = vDynProp + vPropInst.results[intC].ValueDecimal + "|";
} else if (vDynProp + vPropInst.results[intC].ValueString != null) {
vDynProp = vDynProp + vPropInst.results[intC].ValueString + "|";
} else {
vDynProp = vDynProp + "N/A" + "|";
}
}
I am not sure this is the best way, but I am getting the information looking for.
This post is to find out instead of form scripting, how I can get this done through a plugin (Query or LINQ). I have tried the obvious ways . Deployed successfully but getting runtime error:
'OpportunityProduct' entity doesn't contain attribute with Name = 'OpportunityProduct_Dynamicpropertyinstance'.
the LINQ part of my code looks like:
using (myOpportunityContext myContext = new myOpportunityContext(service))
{
var oppProds = from oppProducts in myContext.OpportunityProductSet
join Prods in myContext.ProductSet on oppProducts.ProductId.Id equals Prods.Id
where oppProducts.OpportunityId == myOpp.ToEntityReference()
select new
{
item = Prods.ProductNumber,
vPropInst = oppProducts.OpportunityProduct_Dynamicpropertyinstance
};
// Some Code here
}
Any help appreciated