Jump to content

Task custom fields and their data


Recommended Posts

Hi there,

 

We're currently using the API, raising new activities against a call with custom fields attached to them.

This works perfectly - for example we add a mandatory text field into the activity, and the service desk users can't complete that activity (and therefore the call in their main workflow) until they answer it.

However, we can't seem to get the data that the service desk users actually enter into here once they've completed the custom field.

My assumption is that when I call this:

https://mdh-p01-api.hornbill.com/lbdigitalservices/xmlmc/task/?op=taskGetInfo

... I'd get the values back inside taskAnswers or another property - but whenever call this on a completed task, all I get is the structure of the activity down to <customFields> then the two answer properties are never returned.

Is there something else I need to send in or call (or have special permission) in order to see the actual answers on an activity?

Many thanks,

E.
 

Link to comment
Share on other sites

  • Victor changed the title to Task custom fields and their data

@Edward Melconian @StephenJ - I got the following feedback from dev team:

If the task was completed with outcomes custom fields then outcomeAnswers will be returned, if the custom fields were not answered at the time completing the task then there won't be any values to return. Can you please clarify how is the task is completed? The task custom field used to be an experimental setting, if it is not enabled it then it won't allow the task to provide that info. As per as API is concerned it returns values as expected if the answers are provided at the time of task completion.

Link to comment
Share on other sites

Hi Victor,

We are indeed completing the task with the custom field populated with a value - and the values are not coming back when requesting the getTaskInfo.

Attached are 3 x screens - the first showing the custom task question with custom button; the question is mandatory so if users click complete from your UI the box has to pop up anyway in order for them to complete. They add the value (and the reason also, which is currently mandatory too in this test example - probably not when we actually use this function) , click "ADD CUSTOM INFO" and the task correctly completes.

The second screen shows it in the activity panel on the right.

The 3rd shot shows how it looks after being completed - where in "show more" you can see the custom question, but no answer.

Finally, here's the result of getting this task using getTaskInfo - I've removed anything sensitive to our instance. You'll see that the custom field structure comes back fine, but there's never any custom answer. The completion reason comes back fine too under the <completionDetails> element, but there is no outcomeAnswers element returned:


<?xml version="1.0" encoding="utf-8"?>
<methodCallResult status="ok">
    <params>
        <status>complete</status>
        <title>Test task</title>
        <details>A task that can only be completed when a custom value is added</details>
        <options>
            <timeSpent>true</timeSpent>
            <enforceProgressForCompletion>false</enforceProgressForCompletion>
            <hideReason>false</hideReason>
        </options>
        <priority>normal</priority>
        <appointment>false</appointment>
        <category>Demo category</category>
        <createdOn>2018-10-25 22:55:54Z</createdOn>
        <createdBy>XXXX</createdBy>
        <timeSpent>0</timeSpent>
        <timeBillable>false</timeBillable>
        <progress>100</progress>
        <assignedTo>urn:sys:user:XXX</assignedTo>
        <owner>XXX</owner>
        <outcomes>Complete</outcomes>
        <outcomeInfo>
            <outcome>Complete</outcome>
            <displayName>
                <text>Add custom info</text>
            </displayName>
            <buttonColor>default</buttonColor>
            <requiresReason>true</requiresReason>
            <customFields>
                <id>somefield</id>
                <label>
                    <text>Please enter a value for this custom field</text>
                </label>
                <isSummary>true</isSummary>
                <isMandatory>true</isMandatory>
                <isVisible>true</isVisible>
                <isReadOnly>false</isReadOnly>
                <showIfEmpty>true</showIfEmpty>
                <text></text>
            </customFields>
        </outcomeInfo>
        <outcome>Complete</outcome>
        <private>false</private>
        <completedOn>2018-11-01 10:29:07Z</completedOn>
        <completedBy>XXX</completedBy>
        <showInCalendar>false</showInCalendar>
        <objectRefUrn>urn:sys:entity:com.hornbill.servicemanager:Requests:SR00310130</objectRefUrn>
        <reminder>PT1440M</reminder>
        <remindAssignee>true</remindAssignee>
        <remindOwner>true</remindOwner>
        <completionDetails>This is a reason</completionDetails>
        <application>com.hornbill.core</application>
        <customFields>
            <id>somefield</id>
            <label>
                <text>Please enter a value for this custom field</text>
            </label>
            <isSummary>true</isSummary>
            <isMandatory>true</isMandatory>
            <isVisible>true</isVisible>
            <isReadOnly>false</isReadOnly>
            <showIfEmpty>true</showIfEmpty>
            <text></text>
        </customFields>
    </params>
</methodCallResult>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <ServiceManager_GetTaskResponse
            xmlns="http://brent.gov.uk/adservice/"; />
        </soap:Body>
    </soap:Envelope>


 

 

 

 

 

 

 

 

hornbill_1.png

hornbill_2.png

hornbill_3.png

Link to comment
Share on other sites

hi @Edward Melconian

I'm looking right now at your taskGetInfo result and can't see there taskAnswers tag - should be there if task was containing custom questions and is completed.

Could you create again task with custom question(s) and see what is being send to server when you complete it? I'm interested to see if there is any <taskAnswer> tag (should contain strings similar to this one <taskAnswers><key>field_1</key><value>test</value><displayValue>test</displayValue></taskAnswers>).
Please also mention me when you answer.

Miro

Link to comment
Share on other sites

Hi @Miro

When the task is being completed through the user interface, the dialog box of which includes the custom field shown in the above screenshot, it is only sending across the basic parameters for completing the task - this seems to be part of the issue; it doesn't seem to be POSTing in the custom data back in the first place.

For example, here's the process just run for task TSK20181105000005.

When I enter "reason" into the reason box and "custom" into the custom field here:

image.thumb.png.4f613a951bb2ef563b1995395ed2d89e.png

... and press the custom button marked "ADD CUSTOM INFO", only the following is POSTed - which is missing the custom answer, even though you can see it in the shot above

<methodCall service="task" method="taskComplete" csrf_token="x">

<params><taskId>TSK20181105000005</taskId>

<outcome>Complete</outcome>

<timeSpent>0</timeSpent>

<details>reason</details></params>

</methodCall>

As far as I can see, your API should allow the custom field answers to be sent in at this point, but they don't seem to be sent by the above:

https://mdh-p01-api.hornbill.com/lbdigitalservices/xmlmc/task/?op=taskComplete

Thanks,

E.

Link to comment
Share on other sites

@Edward Melconian could you replicate that and create simple BPM flow with one node "HUMAN TASK". Configure it to replicate problem and then download process and send it to me in private message.
Asking as I can't replicate and this should allow me to do it quite easily.

Many thanks,
Miro

Link to comment
Share on other sites

Hi @Miro

Sorry - I don't understand what you're asking  me to do here.

I'm not able to create BPMs etc, which is done by some of the other admin users. I've asked them if they know what you mean above and will look into it.

For now, to me anyway, it simply looks like your angular controller is ignoring the custom fields on our Hornbill instance, as they don't appear in the POST back to the server.

Thanks,

E.

Link to comment
Share on other sites

@Victor "Api Automation" is a user account. This still doesn't tell me how the task was created. I can only suspect it was with direct API call like task:taskCreate2?
The only way I was trying (and testing) task custom questions was with BPM tasks and here I have never found any problems.

 

Link to comment
Share on other sites

@Victor @Miro

Hi both,

Yes, it's an API call as per the original post. We're using taskCreate2 to call it:

https://mdh-p01-api.hornbill.com/lbdigitalservices/xmlmc/task/?op=taskCreate2

... and to be clear again, that part is working;  the custom fields are appearing and being shown to the users.

It's the POST back to the server after completing the custom fields that isn't giving any data.

We're using your C# API to do it, so I can't give you a direct XML post - but here's a snippet of the C# script which is successfully creating the custom field:                   

 JavaScriptSerializer json_serializer = new JavaScriptSerializer();
                    ExtraFields dc = json_serializer.Deserialize<ExtraFields>(customFields);
                                        
                    List<XmlmcParam> custom = new List<XmlmcParam>();

                    XmlmcParam cId = new XmlmcParam();
                    cId.Name = "id";
                    cId.Value = dc.id;
                    custom.Add(cId);

                    XmlmcParam customLabelText = new XmlmcParam();
                    customLabelText.Name = "text";
                    customLabelText.Value = dc.label;

                    XmlmcParam cName = new XmlmcParam();
                    cName.Name = "label";
                    cName.Value = null;
                    cName.Children.Add(customLabelText);
                    custom.Add(cName);

                    if (!String.IsNullOrEmpty(dc.placeholderText))
                    {
                        XmlmcParam customPlaceholderText = new XmlmcParam();
                        customPlaceholderText.Name = "text";
                        customPlaceholderText.Value = dc.placeholderText;

                        XmlmcParam cP = new XmlmcParam();
                        cP.Name = "placeholderText";
                        cP.Value = null;
                        cP.Children.Add(customPlaceholderText);
                        custom.Add(cP);
                    }
                    if (!String.IsNullOrEmpty(dc.isSummary))
                    {
                        XmlmcParam cS = new XmlmcParam();
                        cS.Name = "isSummary";
                        cS.Value = dc.isSummary;
                        custom.Add(cS);
                    }
                    if (!String.IsNullOrEmpty(dc.isMandatory))
                    {
                        XmlmcParam cM = new XmlmcParam();
                        cM.Name = "isMandatory";
                        cM.Value = dc.isMandatory;
                        custom.Add(cM);
                    }


                    XmlmcParam vis = new XmlmcParam();
                    vis.Name = "isVisible";
                    vis.Value = "true";
                    custom.Add(vis);


                    if (!String.IsNullOrEmpty(dc.showEmpty))
                    {
                        XmlmcParam SE = new XmlmcParam();
                        SE.Name = "showIfEmpty";
                        SE.Value = dc.showEmpty;
                        custom.Add(SE);
                    }

                    XmlmcParam fieldType = new XmlmcParam();
                    fieldType.Name = "text";
                    fieldType.Value = null;
                    custom.Add(fieldType);

                                        
                    xmlmc.AddParam("customFields",  custom);   

Thanks,

E.

 

Link to comment
Share on other sites

hi @Edward Melconian

I used your xml "customFields" in my test task and was able to complete task without any problems.

The best option will be to do following 3 steps:
1)    click on task and see what is being return from server,
2)    complete task and see what is send back to server,
3)    click on task again and see what is being return from server

This will allow me to see what is missing.

Here is a simple screenshot showing in CHROME how to make step 1 & 3:

image.png

 

And what to check in step 2:

image.png

 

If you can do step above it will speed up things a lot as I should have enough info to see at what stage problem appear. Crucial here will be to see what is being send to server in step 2 and then what is being return in step 3.
Also If you can paste results like I did - as screenshots (or if you don't want here then send it via private message).

Hopefully it should be enough to make some progress with this issue.

Thank you,
Miro
 

 

 

 

Link to comment
Share on other sites

Hi @Miro

This info is all earlier in the thread, including the taskComplete POST - but attached are the details again using screenshots as requested.

Here's getTaskInfo before completing the task:

gettaskinfo.thumb.jpg.5f3845eadc4d2f655baa482e0ee5ec1b.jpg

Here's what it looks like before completing in the UI:

thetask_ui.thumb.jpg.40f71a0fcbc885238c415e1dbca3f996.jpg

Here's the POST to taskComplete - note the missing <taskAnswers> node:

taskComplete_POST.thumb.jpg.20a7aab24ee74357542ce0f346a263c8.jpg

Here's getTaskInfo after completing the task - concentrating on the bottom bit of JSON where you'd expect taskAnswers to contain something, but obviously it won't because there is no <taskAnswers> in the POST data to store data in there:

taskanswers_blank.jpg.5f18e1bbc448eb04b3e8b686e0c22189.jpg

Finally, the UI afterwards which again wouldn't have the custom answer in because taskAnswers is blank - even though we entered one at the completion stage:

thetask_ui_after.thumb.jpg.d13b1e913470379f21f350ffab684a0a.jpg

As you can see, getTaskInfo returns the custom fields, but POST to taskComplete does not send any custom answers back.

Additionally in your last screenshot, I can see the end of a </taskAnswers> node but the rest is cut off on the Chrome dev console - what's the full POST on your instance from that please?

To me it just looks like the function sending the custom fields back to the server isn't picking up these values - so perhaps there is just something switched off on our instance of Service Manager?

Thanks,

E.

 

 

 

 

 

 

 

Link to comment
Share on other sites

Thanks @Edward Melconian for quick respond. Indeed in your post there is no custom fields payload. 

Could you check if your instance has this flag set on: experimental.feature.bpm.allowcustomtaskfields

Here you have a full xmlmc payload for complete task call: 
<methodCall service="task" method="taskComplete" csrf_token="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"><params><taskId>TSK20181112000007</taskId><outcome>Completed</outcome><timeSpent>2880</timeSpent><details></details><taskAnswers><key>somefield</key><value>test</value><displayValue>test</displayValue></taskAnswers></params></methodCall>

Anyway, will have a look again as I can't replicate your problem even if I replace my customFields with yours.

Link to comment
Share on other sites

@Edward Melconian @nasimg @StephenJ

I did some investigation and I think I have some answers: The issue here is that the task custom fields work only in conjunction with a business process. I'll try an explain. If the task is designed via the UI, custom fields on tasks can only be configured when designing a business process. If you create a task manually (from within a request or form activities) there is no option to add or configure custom fields. As such, answers to custom fields (and custom fields as a whole) will only be captured in the task if the task is referencing a business process instance. Now I am not sure if this it is coded as such (dev team can advise here) meaning if the intended behaviour is for task custom fields to work in conjunction with a business process instance.

The reason why the issue occurs in a task created using the API (taskCreate2) is that the API call does not allow to send the "reference" and "referenceId" parameters when invoking the API because these parameters are reserved for system use and they are read-only. As such, when the API is invoked directly the correspondent fields in the h_sys_tasks table will not be populated. When the task is created by the business process then these two fields will get populated with the relevant values. This is an example of two tasks associated with a request, one created by the business process (1) and another created using the API (2)

image.png

If task 1 is completed and answers provided they will be captured and stored but when task 2 is completed the answers will not be captured and stored which is the issue we are discussing here. Again, I am not sure if the intended design is this, but @Edward Melconian you can verify the above by creating a test task using the API and then update the h_reference and h_sys_reference values in h_sys_tasks table for that task. Then when completed, the task custom fields answers should be stored and returned by taskCompete and taskGetInfo. I am not sure if you can implement this in your integration (to update those two fields once the task is created) but if you can then perhaps this is a temporary solution to this.

@Miro can you confirm the above and have a look and see if there is anything that can be done?

 

  • Thanks 1
Link to comment
Share on other sites

@Victor your tips were very useful and I was finally able to replicate the issue and fix it. Basically tasks custom questions wasn't designed to work without BPM so I needed to "open" them to also work in that scenario.

@Edward Melconian thank you for your patience. Fix is already on the way. Once it pass few more tests it will be released with our regular release schedule.

Thank you,
Miro

Link to comment
Share on other sites

22 hours ago, Miro said:

@Victor your tips were very useful and I was finally able to replicate the issue and fix it. Basically tasks custom questions wasn't designed to work without BPM so I needed to "open" them to also work in that scenario.

@Edward Melconian thank you for your patience. Fix is already on the way. Once it pass few more tests it will be released with our regular release schedule.

Thank you,
Miro

Hi @Victor can you let us know when its available (assume its a Service Manager build update).

Nasim

Link to comment
Share on other sites

@nasimg - I'm afraid not, tasks are not SM functionality, they are part of Core Collaboration. As such the changes mentioned in this post will be included in a Core Collaboration automatic update. Since Miro mentioned the "fix" is underway I can assume it will be included in the next update. The deployment date is up to the development team. Usually, a Core update happens fortnightly and given that the latest update was last week, I would expect the next update to be sometime next week.

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...