locked
Is it possible to set state of records in MSCRM 2011 using late binding? RRS feed

  • Question

  • Hi Tech Friends,

    Is it possible to set state of records in MSCRM 2011 using late binding?

    We can do it using Service.Execute with SetStateRequest. But can we do it using late binding?


    -Jai


    Thursday, October 24, 2013 2:56 PM

Answers

  • Hi,

    Having said that by David, Late and Early Binding are irrelevant for SetStateRequest.

    The reason being, if you open entity metadata in SDK and see statecode attribute's IsValidForUpdate property that is false. So we couldn't able to update this attribute using Service.Update method. 

    Hope this make sense.


    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !
    Vikram !

    Saturday, October 26, 2013 1:13 PM

All replies

  • Try this modified Sample Code

    // Create an EntityReference to represent an open case EntityReference caseReference = new EntityReference() { LogicalName = "incident", Id = _caseIncidentId }; SetStateRequest state = new SetStateRequest(); // Set the Request Object's Properties state.State = new OptionSetValue(0); //Active

    state.Status = new OptionSetValue(3); //Waiting for Details // Point the Request to the case whose state is being changed state.EntityMoniker = caseReference; // Execute the Request SetStateResponse stateSet = (SetStateResponse)_serviceProxy.Execute(state);


    Regards,

    Ravi


    Thursday, October 24, 2013 3:20 PM
  • I am looking for solution using late binding and not early binding.. There straight forward solution using early binding. I want using late binding.. That is my question.

    -Jai


    Thursday, October 24, 2013 4:51 PM
  • Within CRM development, the terms 'Late Binding' and 'Early Binding' are relevant to distinguish between using the Entity or DynamicEntity class (late binding) or specific entity classes (e.g. account) when manipulating entity attributes. The SetState message does not use either of these types of classes, so as far as I see it the terms 'Late Binding' and 'Early Binding' are irrelevant for SetState.

    What do you mean by 'Late Binding' in the context of your question ?


    Microsoft CRM MVP - http://mscrmuk.blogspot.com/ http://www.excitation.co.uk

    Friday, October 25, 2013 9:02 AM
    Moderator
  • For your question:

    I want to set state of the entity records without using SetStateRequest. I want to use late binding.

    For eg, I am looking for something like this:-

    contact["statecode"] = new OptionSetValue(0);

    contact["statuscode"] = new OptionSetValue(1);

    Is this possible? I see statecode and statuscode attribute part of entity. So why is that it does not work for setting state using late binding?


    -Jai

    Saturday, October 26, 2013 12:41 PM
  • Hi,

    Having said that by David, Late and Early Binding are irrelevant for SetStateRequest.

    The reason being, if you open entity metadata in SDK and see statecode attribute's IsValidForUpdate property that is false. So we couldn't able to update this attribute using Service.Update method. 

    Hope this make sense.


    Hope this helps. If you get answer of your question, please mark the response as an answer and vote as helpful !
    Vikram !

    Saturday, October 26, 2013 1:13 PM
  • it is not depending Early Bind and Latebind

    We can do it only using Service.Execute and using request message

    as you say....

    contact["statecode"] = new OptionSetValue(0);

    contact["statuscode"] = new OptionSetValue(1);

    you doing it by Service.Update()

    So we couldn't able to update these attribute directly using Service.Update method.

    because in crm statecode attribute's "IsValidForUpdate" is set to false.so we cannot update using Service.Update()

    we go for CRM Messages e.g SetState Request.



    Muhammad Sohail

    Saturday, October 26, 2013 4:59 PM