locked
weight data need to be pushed to patient case from weight entity through plugin code RRS feed

  • Question

  • through plugin code how can I push value from weight entity to the Patient Case when a new record is created in Weight entity? please help on this meta:Search.MSForums.ForumID(750a4dad-7650-4aab-ace4-2d5dbcfe8ad2) site:microsoft.com
    Wednesday, June 29, 2011 7:26 AM

Answers

  • Hi,

    Yes workflow will work for all verisons:

    1. Go to Settings->Workflows, Click on New Workflow

    2. In Workflow window Select New Blank Workflow and In Entity Select Weight

    3. In Starts When Select New Record is Created

    4. In Workflow Steps Add Update Record Step (in Drop Download Select Case Entity)

    5. Click on Set Properties, Click on the Weight field in Case entity that you want to update

    6. In Form Assistant -> Dynamics Values Select Weight field that is required to be updated in Case Entity

    7. Click Add button, Save and Publish Workflow

    For creating new worklfow you can also refer to the tutorial video: http://www.youtube.com/watch?v=Lhsae4BLZTw


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    • Proposed as answer by Jehanzeb.Javeed Wednesday, June 29, 2011 8:22 AM
    • Marked as answer by CRM Rajeev Thursday, June 30, 2011 6:03 AM
    Wednesday, June 29, 2011 8:22 AM
  • Wow! Excellent! its really gr8!! I could implemented workflow within 5 min.

     

    Thanks a lot.

     


    • Marked as answer by CRM Rajeev Thursday, June 30, 2011 6:02 AM
    Thursday, June 30, 2011 6:02 AM

All replies

  • through plugin code how can I push value from weight entity to the Patient Case when a new record is created in Weight entity? please help on this
    scenario is as follows:
    first we have the weight entity which will have all the weights for the patient case.
    when the recent weight is added through plugin the weight data need to updated in the weight field available in patient case.
    Please help me on this.
    Thanks in advance.
    Wednesday, June 29, 2011 7:31 AM
  • Hi Rajeev,

    As easiest way is to create new workflow that will trigger on Weight record creation, add Update Record step and Update Case record weight value from Wight entity field.

    I hope this helps.

    Please also mentiuon your CRM version so cna help with plugin code.


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    Wednesday, June 29, 2011 7:39 AM
  • Thanks jehanzeb,

    The CRM version is 4.0.

    Please help me in writing the plugin in this scenario. I am new to CRM.

     

    Thanks,

    Rajeev.

     

     

    Wednesday, June 29, 2011 7:44 AM
  • Hi,

    You can refer the following links for creating, registering a plugin guide:

    http://msdn.microsoft.com/en-us/library/bb955366.aspx

    http://msdn.microsoft.com/en-us/library/bb955365.aspx

    1. Your plugin will trigger on Create event of entity Patient

    2. In plugin code you can retrieve the Case entity lookup via plugin entity case lookup field

    3. Lopokup will give you the case entity id, you can create new simple DynamicsEntity CaseEntity = new DynamicsEntity("incident");

    4. Then can add the property into the Weight property value in to the dynamics  entity

    5. Then can call Service.Update (CaseEntity); to update record

    *Using a woorkflow is much simpler and faster approch (as you will be doing it without coding)


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Wednesday, June 29, 2011 7:52 AM
  • Thanks Javeed for your suggestion on Using a workflow.

    will the workflow work for  on-premise deployment?

    Also, could you provide steps for creating the workflow in this scenario.

     

     

    Regards,

    Rajeev.

     

     

     

    Wednesday, June 29, 2011 8:05 AM
  • Hi,

    Yes workflow will work for all verisons:

    1. Go to Settings->Workflows, Click on New Workflow

    2. In Workflow window Select New Blank Workflow and In Entity Select Weight

    3. In Starts When Select New Record is Created

    4. In Workflow Steps Add Update Record Step (in Drop Download Select Case Entity)

    5. Click on Set Properties, Click on the Weight field in Case entity that you want to update

    6. In Form Assistant -> Dynamics Values Select Weight field that is required to be updated in Case Entity

    7. Click Add button, Save and Publish Workflow

    For creating new worklfow you can also refer to the tutorial video: http://www.youtube.com/watch?v=Lhsae4BLZTw


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    • Proposed as answer by Jehanzeb.Javeed Wednesday, June 29, 2011 8:22 AM
    • Marked as answer by CRM Rajeev Thursday, June 30, 2011 6:03 AM
    Wednesday, June 29, 2011 8:22 AM
  • Wow! Excellent! its really gr8!! I could implemented workflow within 5 min.

     

    Thanks a lot.

     

    Wednesday, June 29, 2011 7:01 PM
  • Hi,

    I am facing one piculiar problem. Plug in code is updating the field of the entity at the runtime. but we are not seeing data updated in the picklist.

    MS dynamic CRM ver - 4.0

    Following is the scenario

    Calling the method UpdateTreatmentCaseInfusionDate which will update the substatus picklist

    CrmDateTime

    actualinfusiondate = (CrmDateTime)posttcinfusion.Properties["invoke_actualinfusiondate"];

     

    Picklist substatuspicklist = new Picklist(8); //"5. Active (On Therapy)"

     

    UpdateTreatmentCaseInfusionDate(context, parentkey, substatuspicklist,

    actualinfusiondate, shouldByPassStatusLogic);

     

     

    The Method

     

     

    private void UpdateTreatmentCaseInfusionDate(IPluginExecutionContext context, string

    parentkey,

     

    Picklist treatmentcasesubstatus, CrmDateTime actualinfusiondate, bool

    bypassstatulogic)

    {

     

    //Get the current header total

     

    ICrmService crmservice = context.CreateCrmService(true

    );

     

    //Add the line total to the header total

     

    DynamicEntity dynentity = new DynamicEntity

    ();

    dynentity.Name =

    "invoke_treatmentcase"

    ;

     

    Guid entityguid = new Guid

    (parentkey);

    Microsoft.Crm.Sdk.

    PropertyCollection properties = new Microsoft.Crm.Sdk.PropertyCollection

    ();

    properties.Add(

    new KeyProperty("invoke_treatmentcaseid", new Key

    (entityguid)));

     

    if (bypassstatulogic == false

    )

    {

     

    Picklist test = new Picklist

    (8);

    properties.Add(

    new PicklistProperty("us_substatus"

    , test));

     

    //properties.Add(new PicklistProperty("us_substatus", treatmentcasesubstatus));

    }

    properties.Add(

    new CrmDateTimeProperty("us_firstinfusiondate"

    , actualinfusiondate));

    properties.Add(

    new CrmDateTimeProperty("us_actual1stinfusiondate"

    , actualinfusiondate));

     

    dynentity.Properties = properties;

     

    TargetUpdateDynamic target = new TargetUpdateDynamic

    ();

    target.Entity = dynentity;

     

    UpdateRequest update = new UpdateRequest

    ();

    update.Target = target;

     

    UpdateResponse updated = (UpdateResponse

    )crmservice.Execute(update);

    }

    

    

    Wednesday, June 29, 2011 7:20 PM
  • The line

    properties.Add(new PicklistProperty("us_substatus", test));

     is working fine at the time of runtime but we are unable to see the data in the record in the database.

    Please help me on this

    Thanks,

    Rajeev

    Wednesday, June 29, 2011 7:23 PM
  • can some one help on this.

     

    Thursday, June 30, 2011 5:30 AM
  • Hi,
     
    Only this field is not updating or all fields are not updating?

    Seems like your  code is fine, have you reigisted plugin step correctly? try debugging a plugin http://msdn.microsoft.com/en-us/library/cc151088.aspx and instead of using:


    TargetUpdateDynamic target =newTargetUpdateDynamic();

    target.Entity = dynentity;

    update.Target = target;

    UpdateResponse updated = (UpdateResponse)crmservice.Execute(update);

     

    Try This:

    crmservice.Update(dynentity);

     


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".


    Thursday, June 30, 2011 5:47 AM
  • Wow! Excellent! its really gr8!! I could implemented workflow within 5 min.

     

    Thanks a lot.

     


    • Marked as answer by CRM Rajeev Thursday, June 30, 2011 6:02 AM
    Thursday, June 30, 2011 6:02 AM