Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to set Lookup field on newly created record from Resco

(1) ShareShare
ReportReport
Posted on by 7

Hello:

I am creating a new Invoice Product record from a Case form in Resco Mobile CRM, and my particular issue is setting the "Existing Product" / 'productid' lookup field to an existing Product record. 

Here are some of the ways I've tried to pass this object along to no avail.

1: Passing the 'productid' the same way I'm passing my 'invoiceid' data results in the invoice product being made but the 'productid' field not being populated by the specified record:

line_item.properties["invoiceid"] = {
 id: editedEntityProps.new_invoiceid.id,
 entityName: "invoice"
};

line_item.properties["productid"] = {

id: getProduct(),
name: product_name,
type: "products"
};

2 Passing the 'productid' explicity as it's own fields by using the following:

line_item.properties["_productid_id"] = getProduct();
line_item.properties["_productid_type"] = "products";

line_item.properties["productname"] = product_name;

3 Creating a reference to a product object, filling with data, and passing: (this one is weird because if the entity name is wrong it stops and throws an error, but if it's correct it doesn't correctly assign the lookup.)

line_item.properties["productid"] = new MobileCRM.Reference("products",getProduct(),product_name);

4 Tried just wrapping all of line_item.properties into one assignment block as so:

line_item.properties = {
invoicedetailname: product_name,
quantity: 1,
csm_toothnumber: getToothId(this.value),
csm_quadrant: getQuadrant(this.value),
invoiceid: { id: editedEntityProps.new_invoiceid.id, entityName: "invoice" },
productname: product_name,
isproductoverridden: false,
ispriceoverridden: false,
productid: { id: getProduct(), name: product_name, type: "products" }
};

As a note, I've tested all variables and functions to produce the correct output. Currently, I am able to create an invoice product with everything except for the 'productid' lookup field/relationship set even though I am able to successfully set 'invoiceid', another lookup field/relationship. 

*This post is locked for comments

  • Thomas David Dayman Profile Picture
    Thomas David Dayman 11,323 on at
    RE: How to set Lookup field on newly created record from Resco

    The 'new MobileCRM.Reference' should work. Have you added some alerts to see what values are being passed into getProduct()? Also the entity name seems incorrect but im sure you have checked this already.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans