Good day. I have a big task, and the last part is sending the document through a web service.

Generally speaking, I need to send not only a document, but an array of objects, among which there are documents. Documents will be in PDF format.

As I could see, the "Content type" field is protected from changes and is always JSON.

Is there any simple (or at least some) way to accomplish the task sent to me?

I have an example of performing this task in Java and there the document is loaded into the stream and then passed as an attribute ContentReference, but I do not understand how to implement this in bpm'online ..

Like 0

Like

3 comments

It's hard to understand where you want to send the document from. From bpm'online to a third party, or vise versa. If it's from bpm'online please do that via c# in a Script task in a business process. If it's vise versa, please use the same web service that we call when we add a new file to a "File" detail. Please use Fiddler in order to find the service name. 

Eugene Podkovka,

Thank you very much, I finally realized that I had to do this through C# in the Script task, but now I have another problem.

I found a code (https://stackoverflow.com/questions/17027159/how-send-a-pdf-by-post-htt…) that converts the PDF file into bytes and sends them via HttpWebRequest, but I don’t know how to get a document file.

I mean, the Server.MapPath method is used in this example, but I cannot do this. I only know that this document should be on the "Attachments and notes" tab in Contact. Is there a way to get a link to the desired document (by name, etc.) Or use the MapPath function?

I am also trying to figure out how to attach more data than just a file, because the file is just one of them. The following is the complete structure:



If you have any suggestions or tips, please, help me.

Dear Pavlo,

Please note that all documents are saved in the database in the appropriate table. For example, documents from the “Attachments and notes” tab from the Contact section are saved in the “ContactFile” table and have the object name “Contact attachment”. Therefore, it’s possible to read it like ordinary data from the database.

Please note that the column with data of the document has name “Data” and type “varbinary(max)”. In order to read data from the database please use “Read data” element of business process or use ESQ in the code of the Script task element.

Please find more detail instructions about reading and using data in the Script task element from the link below:

https://community.bpmonline.com/questions/how-read-entity-lookup-column-script-task

Best regards,

Norton

Show all comments

Hi,

 

Can someone please direct me to any documentation around how to add data to bpmonline when receiving the data through an API?

 

Does the JSON.NET work for bpmonline or do I have to use JavaScriptSerializer class?

Like 0

Like

1 comments

Hi aaykay

Please refer to the below link:

https://academy.bpmonline.com/documents/technic-sdk/7-13/integration-bpmonline-and-public-api

The above link will have all information related to API integration and the management of data recieved through them.

In the below link, you will specifically find how to do CRUD operations in BPMOnline objects like Contacts etc.

https://academy.bpmonline.com/documents/technic-sdk/7-13/working-bpmonline-objects-over-odata-protocol-wcf-client

Thanks

Abinaya

 

 

Show all comments

I've created a webservice that passes the received data from my api to a "Collection of Objects with attributes" parameter inside my business process.

I would like to know how can i convert that business process parameter to a JArray.



JArray jarray = Get("ProcessSchemaCadastros");

This is the line i have in my script task to get my data from business process parameter.

Like 0

Like

2 comments
Best reply

I found a way to pass my problem, instead of trying to convert into a JArray i used:

var entities = Get<ICompositeObjectList<ICompositeObject>>("WebService1.UsrWBCadastros_Out");

then i just worked with the data from 'entities'.

 

It's much easier to transfer a JSON from the web service to a text variable in a business process. Then parse the JSON in the business process.

I found a way to pass my problem, instead of trying to convert into a JArray i used:

var entities = Get<ICompositeObjectList<ICompositeObject>>("WebService1.UsrWBCadastros_Out");

then i just worked with the data from 'entities'.

 

Show all comments

Hi Community,

we have the following problem, when we make a data load through the consumption of a "REST - WebService"

We would like to know how we could fix the "parse" error so that the execution does not fall ?. This happens when reading a JSON from the WebService.

 

 

 

Newtonsoft.Json.JsonException: Unexpected character while parsing path: 

   at Newtonsoft.Json.Linq.JsonPath.JPath.ParseMain()

   at Newtonsoft.Json.Linq.JToken.SelectToken(String path, Boolean errorWhenNoMatch)

   at Terrasoft.Services.Runtime.JsonResponseBodyParser.FillServiceParameterValues(IEnumerable`1 parameters, JToken responseToken, Dictionary`2 parameterValues)

   at Terrasoft.Services.Runtime.JsonResponseBodyParser.FillComplexArray(ServiceParameter parameter, JArray jsonArray)

   at Terrasoft.Services.Runtime.JsonResponseBodyParser.FillArrayValues(JToken token, ServiceParameter parameter, Type valueType)

   at Terrasoft.Services.Runtime.JsonResponseBodyParser.FillServiceParameterValues(IEnumerable`1 parameters, JToken responseToken, Dictionary`2 parameterValues)

   at Terrasoft.Services.Runtime.JsonResponseBodyParser.Parse(String body, Dictionary`2 dataAdapters)

   at Terrasoft.Services.Runtime.ServiceClientResponse.FillInBodyParameters(Dictionary`2 parameterValues)

   at Terrasoft.Services.Runtime.ServiceClientResponse.ParseResponse()

   at Terrasoft.Services.Runtime.ServiceClientResponse.get_ParameterValues()

   at Terrasoft.Services.WebServiceUserTaskImplementation.FillResponseParameters(IServiceClientResponse response, ProcessWebService userTask, IProcessParametersMetaInfo schema)

   at Terrasoft.Services.WebServiceUserTaskImplementation.Execute(ProcessWebService userTask, ProcessExecutingContext context)

   at Terrasoft.Core.Process.ProcessActivity.Execute(ProcessExecutingContext context)

Like 0

Like

1 comments

Hello,



Basically, the error means that system receives an unexpected json object from web service.



If you use business process element "call web service" to make requests to external web service you should check web service settings.



In case you make a request to a web service via script task i.e. c# code, you should check your code for incorrect casts. 



Also you can simply catch requests and responses from web services via fiddler. With fiddler you are able to view headers, body and other request parameters.



Best regards,

Alex

Show all comments

What is the correct way to perform the query in JSON to obtain the records that start with the letter "Y"?

The next JSON get the columns GivenName, MiddleName and Surname from "Contact":

{
    "RootSchemaName":"Contact",
    "OperationType":0,
    "Columns":{
        "Items":{
            "GivenName":{
                "Expression":{
                    "ExpressionType":0,
                    "ColumnPath":"GivenName"
                }
            },
            "MiddleName":{
                "Expression":{
                    "ExpressionType":0,
                    "ColumnPath":"MiddleName"
                }
            },
            "Surname":{
                "Expression":{
                    "ExpressionType":0,
                    "ColumnPath":"Surname"
                }
            }
        }
    },
    "AllColumns":1
}

And return all que records from "Contact".

When I apply the filter GivenName = Yxyxyx

{
    "RootSchemaName":"Contact",
    "OperationType":0,
    "Columns":{
        "Items":{
            "GivenName":{
                "Expression":{
                    "ExpressionType":0,
                    "ColumnPath":"GivenName"
                }
            },
            "MiddleName":{
                "Expression":{
                    "ExpressionType":0,
                    "ColumnPath":"MiddleName"
                }
            },
            "Surname":{
                "Expression":{
                    "ExpressionType":0,
                    "ColumnPath":"Surname"
                }
            }
        }
    },
    "AllColumns":1,
    "Filters":{
        "RootSchemaName":"Contact",
        "FilterType":1,
        "ComparisonType":3,
        "LeftExpression":{
            "ExpressionType":0,
            "ColumnPath":"GivenName"
        },
        "RightExpression":{
            "ExpressionType":2,
            "Parameter":{
                "DataValueType":1,
                "Value":"Yxyxyx"
            }
        }
    }
}

Returns all records with the name GivenName equal to "Yxyxyx"

But an error returned when I sent the query GivenName starts with "Y", like this:

{
    "RootSchemaName":"Contact",
    "OperationType":0,
    "Columns":{
        "Items":{
            "GivenName":{
                "Expression":{
                    "ExpressionType":0,
                    "ColumnPath":"GivenName"
                }
            },
            "MiddleName":{
                "Expression":{
                    "ExpressionType":0,
                    "ColumnPath":"MiddleName"
                }
            },
            "Surname":{
                "Expression":{
                    "ExpressionType":0,
                    "ColumnPath":"Surname"
                }
            }
        }
    },
    "AllColumns":1,
    "Filters":{
        "RootSchemaName":"Contact",
        "FilterType":1,
        "ComparisonType":16,
        "LeftExpression":{
            "ExpressionType":0,
            "ColumnPath":"GivenName"
        },
        "RightExpression":{
            "ExpressionType":2,
            "Parameter":{
                "DataValueType":1,
                "Value":"Y"
            }
        }
    }
}

The error return is:

{
    "responseStatus": {
        "ErrorCode": "SqlException",
        "Message": "Incorrect syntax near '@P1'.",
        "Errors": []
    },
    "rowsAffected": -1,
    "nextPrcElReady": false,
    "success": false
}

 

And, How do you filter two or more columns?

Like 0

Like

2 comments

Try changing the ComparisonType from:

"ComparisonType":16

To 

ComparisonType":9

9 = STARTS_WITH (16 = "NOT_EXISTS)

https://academy.bpmonline.com/api/jscoreapi/7.12.0/index.html#!/api/Ter…

Thank you.

It worked

Show all comments
import json
import requests
 
login_url = "https://my.bpmonline.com/ServiceModel/AuthService.svc/Login"
headers = {"Content-Type": "application/json"}
login_json = {"UserName": "Supervisor", "UserPassword": "password"}
 
# Login and get the session cookie
session = requests.post(login_url, headers=headers, json=login_json)
 
select_url = 'https://my.bpmonline.com/0/dataservice/json/reply/SelectQuery'
 
# Set the http header BPMCSRF to run the JSON query
headers['BPMCSRF'] = session.cookies.get_dict()['BPMCSRF']
 
# The JSON query to DataService
select_contact_json = {
    "RootSchemaName":"Contact",
    "OperationType":0,
    "Columns":{
        "Items":{
            "GivenName":{
                "Expression":{
                    "ExpressionType":0,
                    "ColumnPath":"GivenName"
                }
            },
            "MiddleName":{
                "Expression":{
                    "ExpressionType":0,
                    "ColumnPath":"MiddleName"
                }
            },
            "Surname":{
                "Expression":{
                    "ExpressionType":0,
                    "ColumnPath":"Surname"
                }
            },
            "BirthDate":{
                "Expression":{
                    "ExpressionType":0,
                    "ColumnPath":"BirthDate"
                }
            }
        }
    },
    "AllColumns":1
}
 
select_contact_response = requests.post(select_url, headers=headers, cookies=session.cookies, json=select_contact_json)
select_contact_json_data = json.loads(select_contact_response.text)
 
# print(select_contact_response.status_code)
print(select_contact_response.text)

 

Like 0

Like

Share

0 comments
Show all comments

Hello community



I am working with a business process using the process element [Call Web Service].

The web service configuration and the call are working correctly.

The JSON response is similar to:

{

"$ totalResults": 2,

"$ startIndex": 1,

"$ itemsPerPage": 100,

"$ resources": [

     {

      "$ clave": "t6UJ9A000001",

      "$ Static_state": 200,

      "$ etag": "Yi4EmiUg3xw =",

       "Account": {

             "$ clave": "A6UJ9A0001RU",

             "$ uuid": "00000000-0000-0000-0000-000000000000",

           }

      },

      {

      "$ clave": "t6UJ9A00000B",

      "$ Static_state": 200,

"$ etag": "wMpPUtrfgdA =",

"Account": {

"$ clave": "A6UJ9A0001RX",

"$ uuid": "00000000-0000-0000-0000-000000000000",

}

}

]

}



My goal is to iterate the JSON and finally create tickets in BPM with the source information.

Using a pre-configured page I was able to determine that the parameter where the information is returned is [#WS Step.Response body #]

How can I take this value in a Script Task and process the JSON? or what is the correct procedure to do this?

Previously I should be able to take the value of the parameter [#WS Setp.Success #] to determine if the execution was successful

Thank you!

Good weekend

Like 0

Like

1 comments

get/set a parameter value in a business process script task

var parameter1 = Get<Guid>("Parameter1");

Set("Parameter2", parameter1.ToString());

var parameter2 = Get<string>("Parameter2");

get object of type UserConnection

var userConnection = Get<UserConnection>("UserConnection");

Show all comments

Hi everyone, 

When I try to use the change event to bindTo a function, I get the following error : "Uncaught TypeError: Cannot read property 'changeMethod' of undefined".

In my diff schema, the change event has a bound function: 

{
    "operation": "insert",
    "name": "Product",
    "values": {
        "layout": {
            "colSpan": 12,
            "rowSpan": 1,
            "column": 0,
            "row": 1,
            "layoutName": "MyLayout"
        },
        "bindTo": "MyLookup",
        "contentType": Terrasoft.ContentType.LOOKUP,
        "enabled": true,
        "change": {
            bindTo: "setProduct"
        },
        "contentType": 3
    },
    "parentName": "MyLayout",
    "propertyName": "items",
    "index": 1
}

And I call it's method handler with the following. 

setProduct: function() {
    console.log("Success!");
}

Adding the "change": { bindTo: "setProduct" } causes the page to not load. Is there a way to activate a JavaScript function when a select element on a page is changed? I need to change the values in a corresponding select element based on the value of the preceding select element.

Like 0

Like

1 comments

Hi,

In order to overcome such issue, please, check that you have binded to an existing lookup "MyLookup". Also, you can try another change method approach. 

In the onEntityInitialized function do the following:

onEntityInitialized: function(){
  this.callParent(arguments);
  this.on("change:Product", this.setProduct, this);
}

Hope this helps.

Regards,

Anastasia

Show all comments
Question

I was wondering where I can find the JSON format or record layout for an odata record in Json format; creating a contact record for example.  Can the odata service describe the format?

Thanks 

Like 0

Like

2 comments

It seems the basic format is simple, I jump the gun

  { 

                'Name': 'Test User',

                'Dear': 'TU',

                'Email': 'Tester@TestsMarketNetServices.com',

                'Phone': '6168477992',

                'Notes': 'Testing 123' 

    }

Additional question: Can you nest relationships with the same document, like activities or do they have to be created separately?

John Adkins,

Yes, you have to create them separately. There is not way to nest relationships.

Regards,

Anastasia

Show all comments

Can someone tell me where to find the response codes or error description for landing page posts.

I'm getting  {"SaveWebFormObjectDataResult":"{resultMessage:\"Not allowed request URL.\"",resultCode:-1}""}

File attachments

Like

3 comments

Dear John,

 

The interpretation of the error codes depends on your landing page settings. The message implies that it is the error of the framework you are using and not the HTTP POST code. 

 

Best regards,

Lisa

 

Thanks for your reply ...

This message is differently coming from the post response.  The url returning the response is our BPM site.  I have postman in the middle. 

My question to the community, "is there a list of standard responses or error codes available for form postings?".  I'm sure I'm doing something silly, just wondering what documentation was available.

Thanks again.

 

 

 

I figured out my error - it was silly.

The landing page domain name didn't match the posting url specified in the landing page setup.  It has to be the complete url name, not just the domain name.

 

Show all comments