locked
CRM 2013 Plugin for Account Create Message Pre-Operation - Retrive Attribute Values RRS feed

  • Question

  • In CRM 2013, I am trying to create a Plugin for Account Create for Pre-Operation(20) stage.

    I guess in this scenario, preimage-postimage doesn't exist and also since the record is not created yet, i can not retrive record directly using service.retrive method.

    So, can any one please assist, how can i get all attribute values that being created for account record?? 

    Wednesday, July 16, 2014 12:24 PM

Answers

  • IPluginExecutionContext context = localContext.PluginExecutionContext;
    
    Entity e = (Entity)context.InputParameters["Target"];
    string name = e["name"];

    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Wednesday, July 16, 2014 1:13 PM
    Moderator
  • So does below syntax is also valid??

    string number= (string)e.Attributes["accountnumber"]  

    for some reason, in debug mode, in the immediate window when i run this commands..i don't get values... any idea??

    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 1:18 PM
  • Try to first check if it is available or not

    if(e.Contains("accountnumber"))

    {

    String number =e["accountnmber"]; //not need for casting because it is already a text field

    }


    Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 1:52 PM
    Moderator
  • Any idea why Visual Studio debug Immediate window doesn't show those values?? any way we can verify the values while debugging???

    
    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 2:55 PM
  • you should be able to see it, could share your code...

    Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 3:11 PM
    Moderator
  • I mean, the plugin runs fine and behind the scene those values are correct when i execute. but while debugging, i can not see those values??

    Any idea??

    Also if i use trace service, where do i see the trace log?? is that the same tracing location "Drive:\Program Files\Microsoft Dynamics CRM\Trace         ??? i don't see that is happening.        

    ITracingService trace = localContext.TracingService;

    trace.Trace("account: " +  Number  );

                      


    • Edited by Nicksoft2011 Wednesday, July 16, 2014 3:27 PM
    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 3:27 PM
  • It won't create any trace file instead it will show trace in exception windows if thrown

    Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 3:58 PM
    Moderator
  • when i do that, i got display of error message without any detail and download log file button disabled as shown below. When i go to trace directory, i see log file with this detail. Any idea what could be wrong??

    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 5:35 PM

All replies

  • IPluginExecutionContext context = localContext.PluginExecutionContext;
    
    Entity e = (Entity)context.InputParameters["Target"];
    string name = e["name"];

    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Wednesday, July 16, 2014 1:13 PM
    Moderator
  • So does below syntax is also valid??

    string number= (string)e.Attributes["accountnumber"]  

    for some reason, in debug mode, in the immediate window when i run this commands..i don't get values... any idea??

    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 1:18 PM
  • Try to first check if it is available or not

    if(e.Contains("accountnumber"))

    {

    String number =e["accountnmber"]; //not need for casting because it is already a text field

    }


    Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 1:52 PM
    Moderator
  • Any idea why Visual Studio debug Immediate window doesn't show those values?? any way we can verify the values while debugging???

    
    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 2:55 PM
  • you should be able to see it, could share your code...

    Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 3:11 PM
    Moderator
  • I mean, the plugin runs fine and behind the scene those values are correct when i execute. but while debugging, i can not see those values??

    Any idea??

    Also if i use trace service, where do i see the trace log?? is that the same tracing location "Drive:\Program Files\Microsoft Dynamics CRM\Trace         ??? i don't see that is happening.        

    ITracingService trace = localContext.TracingService;

    trace.Trace("account: " +  Number  );

                      


    • Edited by Nicksoft2011 Wednesday, July 16, 2014 3:27 PM
    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 3:27 PM
  • It won't create any trace file instead it will show trace in exception windows if thrown

    Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 3:58 PM
    Moderator
  • when i do that, i got display of error message without any detail and download log file button disabled as shown below. When i go to trace directory, i see log file with this detail. Any idea what could be wrong??

    • Marked as answer by Nicksoft2011 Wednesday, July 23, 2014 2:59 PM
    Wednesday, July 16, 2014 5:35 PM