Monday, October 28, 2013

Actions, input parameters and “Object reference not set to an instance of an object” exception

During playing with Actions I wrote simple .Net code that invoked execution of an Action:
slick_CustomActionsTestRequest request = new slick_CustomActionsTestRequest()
    BoolInArgument = true,
    DateTimeInArgument = DateTime.Now,
    DecimalInArgument = decimal.Zero

slick_CustomActionsTestResponse response = service.Execute(request) as slick_CustomActionsTestResponse;

During testing I have got really weird and unclear error – “Object reference not set to an instance of an object.”:

After some investigation I understood that in case you have declared input parameters of Entity, EntityReference, EntityCollection, Money, Picklist or string type (even not marked as required!) to make code work without exception you need to pass this parameters: