DWP Catalog - Populate Questions and Answers (only answered)

Version 8
    Share This:

    Hello,

     

    This requirement exist for long time. We want to get a formatted list of our answered Question so we can put it e.g. to Ticket Description

    The solution is actually quite easy as we get the Answered Questions/Answers in Service Broker Context object (even when there is a bug described later). So the idea is to loop through it in a sub-process and prepare the data (I did this on 20.02).

     

    This is the workflow. You can call it in your service by using Call Activity with only parameter SBContext. What you get from the Call Activity will be OutputText whit a list of ONLY ANSWERED questions like:

    Question1Label: Question1Answer

    Question2Label: Question2Answer

    etc....

     

    Steps:

    1) Insert dummy

    This step is required because of the behavior of Insert element. As our OutputText Variable is NULL at the beginning , the Insert would fail. So I put Empty string inside (the double quotes are without a space! this is just wrongly displayed in the interface)

     

    2) Sub Process

    We loop through the Questions and Answers in SBContext and each Entry will be available in Object

     

    3) Exclusive gateway

    - This is again required because of a bug in Catalog. If you use Request Again and empty some Text Field questions, these will be delivered anyway in the Context with "" in the value. Therefore I am checking if the value is not empty.

    - Another check there is for the hidden questions which we use a lot. As there is no special attribute delivered in SBContext I used Tags. Just write hidden into the Internal Tags of hidden questions and those will be not processed.

     

    (${processContext.Object.value} != "") AND (${processContext.Object.tags[0]} != "hidden") AND (${processContext.Object.valueType} != "ATTACHMENT")

     

    4) Length

    This is to get the actual length of the OutputText. Following Insert step needs this as Offset parameter so he knows on which position to insert next "Question and Answer"

     

    5) Insert

    Adding the actual Entry (Question Answer) of the loop to the OutputText (Don't forget the Output Map. It is important).

     

    As written before, this workflow can be called from another Workflow using call activity and the output can be mapped to any other Input (e.g. WorkOrder description).

    Here also export attached.

     

    Njoy

     

    @Edit (30.03.2020): If you use localized service questions. The questions come to the workflow localized and as this script processes only what comes to the workflow, the question labels will be localized according to the language in which the request was submitted. However it is possible to put the e.g. english question label to Tags and adapt this solution.

     

    @Edit (05.05.2020): There is another issue. The Date and Date/Time Answers formatting is not "localized" and "timezoned" as the answer is taken directly from SBContext. The workaround is to mark such Question as hidden (in Tag) and define the answer in the workflow mapping extra after the output from this procedure. It will be at the bottom but not displayed twice and nicely formatted

     

    @Edit (02.09.2020):

    There is quite a worng behavior also OOTB. If you have Question with defined values, then the stored value is set into the variable. not the displayed value.This is mostly wrong as stored value is something what I want to have in workflow where Display Value is what I want to put e.g. into Ticket Notes. You can change the procedure which I provided that the Display Value will be collected. It’s easy:

         In step : Instert

         Field: Insertion

         Instead of this part : ${processContext.Object.value}

         you have to put: ${processContext.Object.displayValue[0]}

         *change only this piece. the rest should stay.