locked
Plugin CRM 4.0 - HELP RRS feed

  • Question

  • Hello guys, I need a little help,

    I am doing a Plugin for CRM 4.0 and I can't find this, if u can help me !

    1) how can I compare an attribute in CRM ? like on a workflow

    IF(status == "open") ? how can I do that ?

     

    ps: this attribube is a "statuscode" in Case Entity, how can I do this ?

    thanks

    Monday, September 19, 2011 12:36 PM

Answers

  • When you have a plugin and you want to find out what is the status of the entity that triggered the plugin, then it depends on the message for which the plugin is registered. For example, if your plugin executes on "update" of "case" then you could access the status of the case like this:

     

    IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
    OptionSetValue stateCode = (OptionSetValue)context.InputParameters["State"];
    OptionSetValue statusCode = (OptionSetValue)context.InputParameters["Status"];
    


    Gonzalo | gonzaloruizcrm.blogspot.com

    Tuesday, September 20, 2011 1:19 PM
    Moderator

All replies

  • try

    crmForm.all.statuscode.SelectedText


    Mohit Agrawal
    Monday, September 19, 2011 12:50 PM
  • but this command is JScript ? or not ?

    I need to do this with a Plugin, in Visual Studio, this code works with plugin ?

    Monday, September 19, 2011 12:58 PM
  • it will be like

    if (stateCode == IncidentState.Active) //its a enum

    {

    }

    here is different states http://technet.microsoft.com/en-us/library/bb959325.aspx

    I hope this helps.

     


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    • Proposed as answer by Amreek Singh Monday, September 19, 2011 1:39 PM
    Monday, September 19, 2011 1:39 PM
  • ok but what I need to put in

    "stateCode" ? I dont know this :(

    Monday, September 19, 2011 2:32 PM
  • Hi sorry buddy,

    statecode  and statuscode are interrelated.

    Statecode value are generally, active and disable. but in incidents

    it is

    statecode     statuscode

    Active      Inprogress --On hold--waiting for detail and research

    Resolved       Resolved 

    Cancelled      Cancelled 

    If you go to the statuscode field you can find the values related to those status code values

    for e.g In Progress it is 1 and for cancelled it is 6. check it what ever you are trying to compare

    use 

    if (statuscode ==1) // Inprogress

    {

     

    }

     

    I don't no if you need this but it may help

    http://social.microsoft.com/Forums/en/crmdevelopment/thread/6acde5b4-3b2b-48d0-8192-4f77e5973734

    I hope this helps.

     

     

     

     


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    • Proposed as answer by Amreek Singh Monday, September 19, 2011 11:51 PM
    • Edited by Amreek Singh Monday, September 19, 2011 11:53 PM
    Monday, September 19, 2011 11:51 PM
  • When you have a plugin and you want to find out what is the status of the entity that triggered the plugin, then it depends on the message for which the plugin is registered. For example, if your plugin executes on "update" of "case" then you could access the status of the case like this:

     

    IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
    OptionSetValue stateCode = (OptionSetValue)context.InputParameters["State"];
    OptionSetValue statusCode = (OptionSetValue)context.InputParameters["Status"];
    


    Gonzalo | gonzaloruizcrm.blogspot.com

    Tuesday, September 20, 2011 1:19 PM
    Moderator