web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Help creating a task using CRM SDK 2011

(0) ShareShare
ReportReport
Posted on by 615

Hello,

I am trying to create a task using CMR SDK 2011 and I am getting the error "System.ServiceModle.FaultException 1[Micorsoft.Xrm.Sdk.Orginization.ServiceFault]: Required field 'Status' is missing (Fault Detail is equal to Micorsoft.Xrm.Sdk.Orginization.ServiceFault).

Code used is below:

'create the task first

           Dim tsk As New Task

           tsk.RegardingObjectId = acct.ToEntityReference

           tsk.Subject = "Support Package Email Sent " + Now.ToString

           tsk.Category = "Support Package Email"

           tsk.ActualDurationMinutes = 1

           tsk.ActualStart = Now

           tsk.Description = "Email notification sent"

           Dim tskid As Guid = _xrm.Create(tsk)

Any suggestions are greatly appreciated!

Thanks,

Russell

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at

    Hi, to Create a Task,

    You can refer to this SDK Code :

    msdn.microsoft.com/.../gg594416.aspx

    In this part, especially :

    ' Create a task activity to follow up with the account customer in 7 days.

                           Dim followup As New Entity("task")

                           followup("subject") = "Send e-mail to the new customer."

                           followup("description") = "Follow up with the customer. " _

                               & "Check if there are any new issues that need resolution."

                           followup("scheduledstart") = Date.Now.AddDays(7)

                           followup("scheduledend") = Date.Now.AddDays(7)

                           followup("category") = context.PrimaryEntityName

                           ' Refer to the account in the task activity.

                           If context.OutputParameters.Contains("id") Then

                               Dim regardingobjectid As _

                                   New Guid(context.OutputParameters("id").ToString())

                               Dim regardingobjectidType As String = "account"

                               followup("regardingobjectid") =

                                   New EntityReference(regardingobjectidType,

                                                       regardingobjectid)

                           End If

                           ' Obtain the organization service reference.

                           Dim serviceFactory As IOrganizationServiceFactory =

                               CType(serviceProvider.GetService(GetType(IOrganizationServiceFactory)),

                                   IOrganizationServiceFactory)

                           Dim service As IOrganizationService =

                               serviceFactory.CreateOrganizationService(context.UserId)

                           ' Create the task in Microsoft Dynamics CRM.

                           tracingService.Trace("FollowupPlugin: Creating the task activity.")

                           service.Create(followup)

    Hope it helps.

    Thanks.

  • Russell Bahr Profile Picture
    615 on at

    Thanks for the help.  Your sample got things working for me.  Below is the exact code I used along with the request to update the state.

    Dim followup As New Entity("task")

               followup("subject") = "Support Package Email Sent " + Now.ToString

               followup("description") = "Email notification sent regarding remaining time on support package. " + Now.ToString

               followup("scheduledstart") = Date.Now

               followup("scheduledend") = Date.Now

               'followup("category") = context.PrimaryEntityName

               ' Refer to the account in the task activity.

               followup("regardingobjectid") = acct.ToEntityReference

               Dim taskGuid As Guid = _xrm.Create(followup)

               'set the tasks state to completed

               Dim orgreq As OrganizationRequest = New OrganizationRequest("SetState")

               Dim state As OptionSetValue = New OptionSetValue(1)

               orgreq("State") = state

               Dim status As OptionSetValue = New OptionSetValue(5)

               orgreq("Status") = status

               orgreq("EntityMoniker") = New EntityReference("task", taskGuid)

               _xrm.Execute(orgreq)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans