How to get one entity values and create record in other entity

Question Status

Suggested Answer
madiri asked a question on 7 Oct 2017 10:48 AM

Hi All,

I am new to plugin in crm 2016.I am trying to create a plugin for case entity and invoice.I have custom field name casetype(data type is optionset) i want to get that values and if the case type is incident i can select case type when creating or later i can change case type in update too  then i want to get create a record  in invoice with case title and assign case id to caseid  (lookup field)    its a relation to  invoice.

Thank You

Reply
Suggested Answer
Pavan Manideep Yaragani responded on 7 Oct 2017 1:49 PM

Hi Madiri,

You could try to get the values of the field in the First Entity(Case) either through the Plugin Context or through the image created for this Case entity containing this custom field and by comparing it's value as per your exact need and requirement.

If the condition was met, then you could include code like below to complete this, remember you should retrieve _InvoiceId,_Casetitle from the Post image.

   invoice Invoiceentity = new invoice

               {

                   Id = _InvoiceId,

                   Casetitle = _Casetitle,

                };

service.Update(Invoiceentity);

Hope this would help you to the best.

Thanks,

PMDY

Reply
Suggested Answer
Pavan Manideep Yaragani responded on 7 Oct 2017 1:49 PM

Hi Madiri,

You could try to get the values of the field in the First Entity(Case) either through the Plugin Context or through the image created for this Case entity containing this custom field and by comparing it's value as per your exact need and requirement.

If the condition was met, then you could include code like below to complete this, remember you should retrieve _InvoiceId,_Casetitle from the Post image.

   invoice Invoiceentity = new invoice

               {

                   Id = _InvoiceId,

                   Casetitle = _Casetitle,

                };

service.Update(Invoiceentity);

Hope this would help you to the best.

Thanks,

PMDY

Reply