locked
crm4 custom vb.net to CRM2013 RRS feed

  • Question

  • Hi

    I am new to CRM however I have good working knowledge of vb.net

    my client has the following code in an external app to update incident in CRM.

    I have installed crm2013 SDK and have been battling to find a decent vb.net example. Anyone able to point me in the right direction please?

     Dim resolution As New incidentresolution
    
                resolution.timespent = New CrmNumber
                resolution.timespent.Value = 0
                resolution.subject = Mid(strReason, 1, 99)
                resolution.incidentid = New Lookup
                resolution.incidentid.Value = New Guid(sCase)
                resolution.actualend = New CrmDateTime()
                resolution.actualend.Value = Now.ToString("s")
    
                Dim closerequest As New CloseIncidentRequest
                closerequest.IncidentResolution = resolution
                closerequest.Status = 5
                Dim response As New CloseIncidentResponse
    
      Try
                    'response = gService.Execute(closerequest)
                Catch soapEx As System.Web.Services.Protocols.SoapException
                    'soapEx.Detail.InnerText
                    LogWorkflowError("ResolveCase", soapEx.Detail.InnerText, sCase)
                End Try
            Catch ex As Exception
                LogWorkflowError("ResolveCase", ex.Message, sCase)
            End Try

    The problem I have is that even after I reference xrm.sdk and crm.sdk I still dont get types of "incident" or "resolution".

    Thanks for looking.

    Thursday, June 4, 2015 11:33 AM

All replies

  • I'm not well versed in VB.NET, but you may be missing the file needed that would define Incident, IncidentResolution etc as classes.

    In the SDK BIN directory, you run the CRMSVCUTIL console application to generate a class file that contains the definitions of all the CRM entities as classes.

    I did find this blog post by searching on "crmsvcutil vb.net".  You might need to generate the CS file, compile that into an assembly, then reference it in your VB.NET project.

    Good Luck, I hope this helps point you in the right direction.


    Thursday, June 4, 2015 12:23 PM
  • If you wan´t crm typed objects to work with, you will need to add a webservice to your solution or do what Chris_Harrington is talking about.

    When you include the dll from the sdk you should just use the Entity class (it is a dynamic class of entities from crm and is not type specificm, is Late Bound.)

    So your code would be something like...

    Dim resolution As New Entity resolution["timespent"] = 0; resolution["subject"] = Mid(strReason, 1, 99) resolution["incidentid"] = New Guid(sCase) resolution["actualend"] = Now.ToString("s") //The following code needs to change probably to

    Dim stateRequest As New SetStateRequest
    stateRequest.EntityMoniker = resolution
    stateRequest.SetState = New OptionSetValue(1)
    stateRequest.SetStatus = New OptionSetValue(5)
    //...Something close to the above.. For the rest inside the try see C# code below Try 'response = gService.Execute(stateRequest) Catch soapEx As System.Web.Services.Protocols.SoapException 'soapEx.Detail.InnerText LogWorkflowError("ResolveCase", soapEx.Detail.InnerText, sCase) End Try Catch ex As Exception LogWorkflowError("ResolveCase", ex.Message, sCase) End Try

    Here you can read more about the organization service and what message you have there.

    https://msdn.microsoft.com/en-us/library/gg309482.aspx

    This is how you set the state in C#, it should be simple for you to convert this code to vb.

    the service object is probably a OrganizationServiceProxy object.

    SetStateRequest setStateRequest = new SetStateRequest();
     {
     setStateRequest.EntityMoniker = new EntityReference(new_employeelabourtimespentactivity.EntityLogicalName, empllabouractivity);
    
    // Set the State and Status OptionSet Values to Completed.
    setStateRequest.State = new OptionSetValue(1);
     setStateRequest.Status = new OptionSetValue(2);
     };
     SetStateResponse setStateResponse = (SetStateResponse)service.Execute(setStateRequest);
    Hope this helps


    Halldór Jóhannsson








    Thursday, June 4, 2015 1:08 PM
  • You can also download the CRM 2013 SDK - http://www.microsoft.com/en-us/download/details.aspx?id=40321

    There are VB code examples in the sample folder and I am positivite there is something there that can help you tackle this problem.


    Halldór Jóhannsson

    Thursday, June 4, 2015 1:27 PM