Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Answered

Plugins for two enties

Posted on by 160

Hi

I have 2 entities "Payment Transection" and "membership". i want to change the membership status to "Active" when membership status is changed(or created) to "Paid". I m facing problems when m trying to update the status of membership. 

if (!context.InputParameters.ContainsKey("Target"))

throw new InvalidPluginExecutionException("No target found");
var entity = context.InputParameters["Target"] as Entity;

if (entity.LogicalName == "tpamm_paymenttransaction")
{
if (entity.Contains("statecode") && entity["statecode"] != null)
{
OptionSetValue status = (OptionSetValue)entity["statecode"];
int selectedTopicValue = status.Value;


if (selectedTopicValue == 0)
{
entity["tpamm_aggg"] = 23;    //this code is working upto this line. aggg field is 23 after saving.


var entity2 = new Entity("tpamm_MemberShip");

if (entity2.LogicalName == "tpamm_membership")
{


if (entity2.Contains("tpamm_status"))
{
entity2["tpamm_status"] = 239730001;
entity2["statuscode"] = 1;

}

}

Categories:
  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,958 Super User on at
    RE: Plugins for two enties

    Hi,

    If your issue is resolved then please mark my answer verified by clicking on Yes under Did this answer your question?

    78206.PNG

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • happysingh0009 Profile Picture
    happysingh0009 160 on at
    RE: Plugins for two enties

    Thank you for your reply.

  • Verified answer
    Bipin D365 Profile Picture
    Bipin D365 28,958 Super User on at
    RE: Plugins for two enties

    Hi,

    Where is service.update(entity2) code which will update the second entity?

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • happysingh0009 Profile Picture
    happysingh0009 160 on at
    RE: Plugins for two enties

    these two tables are connected through lookup. the transection entity have membershipID lookup from membership table

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans