Service Manager Job - Obtain Task details of a task  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Service Manager Job - Obtain Task details of a task

Postby indikad » Fri Aug 15, 2014 4:17 pm

I need to iterate through the several tasks and obtain the task details such as status , description, AssigneTo etc ( all the details on the Main Tab ) -

also need to get the Status value of the main screen (the one next to priority field ) - seems this field could be called "stausUltraTextEditor" but not visible for me.

any hep is appreciated.
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Service Manager Job - Obtain Task details of a task

Postby Mike.Sheen » Fri Aug 15, 2014 4:47 pm

indikad wrote:I need to iterate through the several tasks and obtain the task details such as status , description, AssigneTo etc ( all the details on the Main Tab ) -


The Job class has a property named Tasks which is a collection of class Task. The Task class has properties such as priority, etc.

indikad wrote:also need to get the Status value of the main screen (the one next to priority field ) - seems this field could be called "stausUltraTextEditor" but not visible for me.


Use the business logic property, not controls to get or set such properties. Only ever interact with the GUI if you want to change the way things appear.

The status is displayed in a control named StatusUltraTextEditor. By "not visible" for you, I assume you mean via code? It should be - it is declared as Public. If you're not using the current version (07.00.78.00) then it's possible that field was not public in your version. Anyway - like I said earlier - use the business logic instead - The Job Class has a Status property which is a complex type - and probably the Name property of that is what you want - i.e.: Job.Status.Name.

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: Service Manager Job - Obtain Task details of a task

Postby indikad » Wed Aug 20, 2014 3:27 pm

TasksJiwaJobScreenshot.png
Hi Mike - thanks for that quick reply - I manage to get the status ( did not expect the property to be Name - was looking for a text property ).

Can you please help me with iterating through the tasks - much appreciated. see attached screenshot (TasksJiwaJobScreenshot.png )
What I need to do is to iterate each tasks - and get the values of the tasks - essentially the task description of each
the following code only gets me the first task.

Code: Select all
If TypeOf JiwaBusinessLogic Is JiwaServiceManager.Job  Then
         Dim oJiwaJob As JiwaServiceManager.Job = DirectCast(JiwaBusinessLogic, JiwaServiceManager.Job)
         AddHandler oJiwaJob.SaveEnd, AddressOf JobSaveEnd
      End If
    End Sub
   Private Sub JobSaveEnd (sender As Object, e As System.EventArgs)
      Dim Jb As JiwaServiceManager.Job = DirectCast(sender, JiwaServiceManager.Job)
      
      Try
         MessageBox.Show("status  = " + jb.Status.Name )      
         MessageBox.Show("main task description ?  = " +    jb.Tasks.Job.Description  )      
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Service Manager Job - Obtain Task details of a task

Postby Mike.Sheen » Wed Aug 20, 2014 4:22 pm

Hi Indika,

This will do what you want - I've just modified your JobSaveEnd method and added an iteration of the tasks to it.

Code: Select all
Private Sub JobSaveEnd (sender As Object, e As System.EventArgs)
      Dim Jb As JiwaServiceManager.Job = DirectCast(sender, JiwaServiceManager.Job)

      Try
         MessageBox.Show("status  = " + jb.Status.Name )     
         MessageBox.Show("main task description ?  = " +    jb.Tasks.Job.Description)
            
         For Each task As JiwaServiceManager.Task In jb.Tasks
            MessageBox.Show(String.Format("Task {0} has a description of '{1}' and a Status Of '{2}'", task.TaskNo, task.Description, task.Status.Name))
         Next
            
            
      Catch Ex As System.Exception
            
      End Try
         
   End Sub
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: Service Manager Job - Obtain Task details of a task

Postby indikad » Wed Aug 20, 2014 4:44 pm

Thanks very much Mike.
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Service Manager Job - Obtain Task details of a task

Postby indikad » Fri Aug 22, 2014 1:38 pm

Hi Mike - when you have a chance can you please give me a tip here.
I am trying to read and update a custom field within a Job-task. since its kind of related to the current topic I will post here.
I can read in a loop or by number but do not know how to read ( and write ) by the fieldname. Which is what I want.
also the update code below errors on run time with a message "insert statement failed ......"

Code: Select all
For Each oTask As JiwaServiceManager.Task In jb.Tasks
               MessageBox.Show(String.Format("Task {0} has a description of '{1}' and a Status Of '{2}' ", oTask.TaskNo, oTask.Description, oTask.Status.Name  ))            
            For Each oCustomFieldVal As JiwaApplication.CustomFields.CustomFieldValue In oTask.CustomFieldValues
               MessageBox.Show("custom field item no = " + oCustomFieldval.CustomField.ItemNo.ToString() + "    field value = " + oCustomFieldval.Contents.ToString() )
               If  oCustomFieldval.CustomField.ItemNo = 1 Then
                  If  oCustomFieldval.CustomField.ItemNo = 2 Then
                     oCustomFieldval.Contents = True
                     oCustomFieldval.SaveRecord()
                  End If
                  If  oCustomFieldval.CustomField.ItemNo = 1 Then
                     oCustomFieldval.Contents = "test value"
                     oCustomFieldval.SaveRecord(oCustomFieldval.RecID)
                  End If
               End If
               'MessageBox.Show(oCustomFieldval.CustomField.
            Next
            For Each oCustomFld As JiwaApplication.CustomFields.CustomField  In jb.TaskCustomFields
               
            Next
            Next
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Service Manager Job - Obtain Task details of a task

Postby Mike.Sheen » Mon Aug 25, 2014 10:08 am

indikad wrote:Hi Mike - when you have a chance can you please give me a tip here.
I am trying to read and update a custom field within a Job-task. since its kind of related to the current topic I will post here.
I can read in a loop or by number but do not know how to read ( and write ) by the fieldname. Which is what I want.
also the update code below errors on run time with a message "insert statement failed ......"


Just examine the custom field name the value is associated with - i.e.:
Code: Select all
For Each task As JiwaServiceManager.Task In jb.Tasks
         MessageBox.Show(String.Format("Task {0} has a description of '{1}' and a Status Of '{2}'", task.TaskNo, task.Description, task.Status.Name))
         For Each customFieldValue As JiwaApplication.CustomFields.CustomFieldValue In task.CustomFieldValues
            If customFieldValue.CustomField.PluginCustomField.Name = "MyCustomField" Then
               customFieldValue.Contents = "MyValue"
               Exit For
            End If
         Next
      Next
         
      jb.Save()


The insert error you are getting is probably because you are calling the Save method of the custom field. You should be using the Save method of the job, as shown above, when you want to commit the changes to the database.

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: Service Manager Job - Obtain Task details of a task

Postby indikad » Mon Aug 25, 2014 8:02 pm

Hi Mike,

thanks - can get to change the value of the custom field now - but saving still gives an error
tried the SaveEnding event as well .
Code: Select all
"unable to update module SM_jobs Module : Save"


in the meantime need to grab the values of the address parts ( tasks - main tab - bottom right hand side - street , suburb , state etc ...)
help is appreciated!!!
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: Service Manager Job - Obtain Task details of a task

Postby Mike.Sheen » Mon Aug 25, 2014 8:25 pm

indikad wrote:thanks - can get to change the value of the custom field now - but saving still gives an error
tried the SaveEnding event as well .


Can you provide an xml export of the plugin which demonstrates the problem? You should be able to attach it to a post here if you rar the xml file.

indikad wrote:in the meantime need to grab the values of the address parts ( tasks - main tab - bottom right hand side - street , suburb , state etc ...)
help is appreciated!!!


The Task class has a BillingAddress property, which is a complex type having properties such as Address1, Address2, et cetera. So - task.BillingAddress.Address1, task.BillingAddress.Address2, etc is probably what you are looking for.

Mike
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: Service Manager Job - Obtain Task details of a task

Postby indikad » Mon Aug 25, 2014 9:33 pm

code attached. Thanks.
Attachments
JobPlugins.rar
job plugins - tester code and custom fields.
(8.32 KiB) Downloaded 152 times
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron