locked
Unable to reactivate a campaign response RRS feed

  • Question

  • Hi All,

    I am trying to reactivate a campaign response which has been closed using code written with the SDK:

            'check how to close the campaign response
            DebugMsg("about to close cr")
            Dim crstate As SetStateCampaignResponseRequest = New SetStateCampaignResponseRequest
    
            'if the action is to create a lead or mark this as completed
            If strAction = "CONVERT" Or strAction = "CONVERT_OPEN" Or strAction = "COMPLETED" Then
                DebugMsg("about to set cr as closed")
                crstate.CampaignResponseState = CampaignResponseState.Closed
                crstate.CampaignResponseStatus = 2
            End If
    
            'if the action is to cancel the lead...
            If strAction = "CANCELED" Then
                DebugMsg("about to set cr as cancelled")
                crstate.CampaignResponseState = CampaignResponseState.Canceled
                crstate.CampaignResponseStatus = 3
            End If
    
            'update the campaign response to close it...
            crstate.EntityId = New Guid(campid)
            DebugMsg("about to execute state update")
            service.Execute(crstate)
            DebugMsg("cr state updated")

    However, when i try to reactiavate a campaign response closed like this i keep getting an error saying the Campaign Response is read-only: Try Again or Cancel. I have checked in the backend SQL database and the statecode = 1 and status=2 as it should. can anyone see why it is not being set correcly?? Am i not setting another propertly/value that i should be???

    Thank you all in advance for your time and help! :-)

    Friday, April 9, 2010 10:45 AM

Answers

  • // For Canceled
    try
                {
                    SetStateCampaignResponseRequest req = new SetStateCampaignResponseRequest();
                    req.CampaignResponseState = CampaignResponseState.Canceled;
                    req.CampaignResponseStatus = 3;
                    req.EntityId = new Guid("DF79A569-8431-DF11-991C-00155D3C0B2B");
                    SetStateCampaignResponseResponse rsp = new SetStateCampaignResponseResponse();
                    rsp = (SetStateCampaignResponseResponse)crmService.Execute(req);
                }
                catch (System.Web.Services.Protocols.SoapException ex)
                { }
    
    // For Closed
    try
                {
                    SetStateCampaignResponseRequest req = new SetStateCampaignResponseRequest();
                    req.CampaignResponseState = CampaignResponseState.Closed;
                    req.CampaignResponseStatus = 2;
                    req.EntityId = new Guid("DF79A569-8431-DF11-991C-00155D3C0B2B");
                    SetStateCampaignResponseResponse rsp = new SetStateCampaignResponseResponse();
                    rsp = (SetStateCampaignResponseResponse)crmService.Execute(req);
                }
                catch (System.Web.Services.Protocols.SoapException ex)
                { }
    
    
    // For Open
    try
                {
                    SetStateCampaignResponseRequest req = new SetStateCampaignResponseRequest();
                    req.CampaignResponseState = CampaignResponseState.Open;
                    req.CampaignResponseStatus = 1;
                    req.EntityId = new Guid("DF79A569-8431-DF11-991C-00155D3C0B2B");
                    SetStateCampaignResponseResponse rsp = new SetStateCampaignResponseResponse();
                    rsp = (SetStateCampaignResponseResponse)crmService.Execute(req);
                }
                catch (System.Web.Services.Protocols.SoapException ex)
                { }

    These three code snipts i test on my crm org and all are working fine.

     


    http://www.allaboutdynamics.com
    Friday, April 9, 2010 12:51 PM

All replies

  • Hi,

    Try to change your code like

    Dim crstate as New SetStateCampaignResponseRequest()

    'if the action is to create a lead or mark this as completed
            If strAction = "CONVERT" Or strAction = "CONVERT_OPEN" Or strAction = "COMPLETED" Then
                DebugMsg("about to set cr as closed")
                crstate.CampaignResponseState = CampaignResponseState.Closed
                crstate.CampaignResponseStatus = 2
            End If

            'if the action is to cancel the lead...
            If strAction = "CANCELED" Then
                DebugMsg("about to set cr as cancelled")
                crstate.CampaignResponseState = CampaignResponseState.Canceled
                crstate.CampaignResponseStatus = 3
            End If
    crstate.EntityId = New Guid(campid)
    Dim Response As SetStateCampaignResponseResponse= CType(service.Execute(crstate), SetStateCampaignResponseResponse)

     and see if it works


    Mahain
    Friday, April 9, 2010 10:56 AM
    Moderator
  • :-( unfortuanately not! same error...
    Friday, April 9, 2010 11:07 AM
  • Canceled 2 Specifies that the campaign response is canceled. Canceled 3
    Closed 1 Specifies that the campaign response is closed. Closed 2
    Open 0 Specifies that the campaign response is open. Open 1

    Above are CampaignResponseState
    What you want to do reactivate or canceled/closed?
    http://www.allaboutdynamics.com
    Friday, April 9, 2010 11:15 AM
  • i want to reactivate a closed and canceled campaign response. my code does set the statecode and statuscode in the database correctly as per your table. but for whatever reason, i am unable to reactivate a campaign response i close using this method. :-( i have double checked in an environment which hasn't got my custom code and when i close a campaign response, it sets the state/statuscode to those in your table. but i can reactivate them.

    am i missing something in my code? should i somehow be setting the campaign response to close AND NOT read only? is there something i am doing wrong?

    Friday, April 9, 2010 12:14 PM
  • ok, i have just done another test - i created a new campaign response, then in the database, i set statecode=1 and statuscode=2 using an SQL update (not via crm). when i refreshed the campaign response i could see it was read only and the status had been updated to 'closed'. however, if i tried to reactivate the campaign response it still gives me the same error! i think there is one more attribute that should be updated when using code to close a campaign response. anyone know what it is??? :-(
    Friday, April 9, 2010 12:20 PM
  • // For Canceled
    try
                {
                    SetStateCampaignResponseRequest req = new SetStateCampaignResponseRequest();
                    req.CampaignResponseState = CampaignResponseState.Canceled;
                    req.CampaignResponseStatus = 3;
                    req.EntityId = new Guid("DF79A569-8431-DF11-991C-00155D3C0B2B");
                    SetStateCampaignResponseResponse rsp = new SetStateCampaignResponseResponse();
                    rsp = (SetStateCampaignResponseResponse)crmService.Execute(req);
                }
                catch (System.Web.Services.Protocols.SoapException ex)
                { }
    
    // For Closed
    try
                {
                    SetStateCampaignResponseRequest req = new SetStateCampaignResponseRequest();
                    req.CampaignResponseState = CampaignResponseState.Closed;
                    req.CampaignResponseStatus = 2;
                    req.EntityId = new Guid("DF79A569-8431-DF11-991C-00155D3C0B2B");
                    SetStateCampaignResponseResponse rsp = new SetStateCampaignResponseResponse();
                    rsp = (SetStateCampaignResponseResponse)crmService.Execute(req);
                }
                catch (System.Web.Services.Protocols.SoapException ex)
                { }
    
    
    // For Open
    try
                {
                    SetStateCampaignResponseRequest req = new SetStateCampaignResponseRequest();
                    req.CampaignResponseState = CampaignResponseState.Open;
                    req.CampaignResponseStatus = 1;
                    req.EntityId = new Guid("DF79A569-8431-DF11-991C-00155D3C0B2B");
                    SetStateCampaignResponseResponse rsp = new SetStateCampaignResponseResponse();
                    rsp = (SetStateCampaignResponseResponse)crmService.Execute(req);
                }
                catch (System.Web.Services.Protocols.SoapException ex)
                { }

    These three code snipts i test on my crm org and all are working fine.

     


    http://www.allaboutdynamics.com
    Friday, April 9, 2010 12:51 PM