web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer Service forum

Custom Action - Unable to pass entityreference to entitycollection

(0) ShareShare
ReportReport
Posted on by 385

I am trying to pass entitycollection input(productlines) to customaction as below but in context i am not getting the field productid(lookup) in the inputparameter but i am able to see the other input like text(sequencenumber).

I have followed the below link: www.inogic.com/.../

Can you please validate my code and let me know incase any modification.

function Action_Opportunity(TargetID, SourceID, FormType) {
    var parameters = {};
    parameters.ipFormType = FormType;
    parameters.ipOpportunityProducts = GetOpportunityProductByType(FormType);
    parameters.ipTargetOpportunityId = TargetID;
}

function GetOpportunityProductByType(FormType) {
    var ecOpportunityProducts = [];
    if (FormType != "onload") {
        var _tabledata = table.getData();
        for (var i = 0; i < _tabledata.length; i++) {
            var entOpportunityProducts = new Object();
            entOpportunityProducts["sequencenumber"] = _tabledata[i].LineNumber;

            // Try1
            entOpportunityProducts["productid"] = _tabledata[i].ProductID != "" ? { "@odata.type": "Microsoft.Dynamics.CRM.product", "productid": _tabledata[i].ProductID, "@odata.Name": "product" } : null;

            //Try2
            var erProduct = {};
            erProduct.opportunityproductid = _tabledata[i].ProductID;
            erProduct["@odata.type"] = "Microsoft.Dynamics.CRM.product";
            entOpportunityProducts["productid"] = erProduct;

            ecOpportunityProducts.push(entOpportunityProducts);
        }
    }   
    return ecOpportunityProducts;
}

Categories:
I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Customer Service

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans