LogicApps with different data schema - azure-logic-apps

I have the following HTTP Post with the following payload
{
"externalCode": "999",
"name": "PNNL - Winthrop, WA (Sundown L",
"description": "Winthrop",
"geozoneFlx": "PNL",
"status": "A",
"address1": "135 Sundown Lane",
"city": "WINTHROP",
"state": "WA",
"county": "OKANOGAN",
"country": "USA",
"zipCode": "98862-0339",
"timezone": "PST",
"startDate": "2016-01-27T00:00:00",
"endDate": "9999-12-31T00:00:00"
},
HOWEVER, some data message come into the Logic App looking like this with no "State" "name" in the data like this
"externalCode": "999",
"name": "PNNL - Winthrop, WA (Sundown L",
"description": "Winthrop",
"geozoneFlx": "PNL",
"status": "A",
"address1": "135 Sundown Lane",
"city": "WINTHROP",
"county": "OKANOGAN",
"country": "USA",
"zipCode": "98862-0339",
"timezone": "PST",
"startDate": "2016-01-27T00:00:00",
"endDate": "9999-12-31T00:00:00"
},
I have to say if the data message comes in without the State json Name like above, kick it out. How do I filter for a missing json field such as "State" in the above??
Thanks
Mike

I think you can judge whether the length of the value of the state field is greater than 0, if it is greater than 0, execute your original logic, if the length of the value is 0, you don't need to do anything. The design of the logic app is as follows:
If the request body of your http request is a json array, you can use the for each loop to process.
The expression for obtaining the length of the state field in condition is as follows:
length(coalesce(body('Parse_JSON')?['state'], ''))
For the usage of coalesce and length, you can refer to the official documentation

Related

Deutschebahn API for departureboard not showing destination station

From this link:
https://developer.deutschebahn.com/store/apis/info?name=Fahrplan-Free&version=v1&provider=DBOpenData#!/default/get_departureBoard_id
I can successfully call the ARRIVALboard information:
[
{
"name": "ICE 1689",
"type": "ICE",
"boardId": null,
"stopId": 8000152,
"stopName": "Hannover Hbf",
"dateTime": "2021-01-19T00:00",
"origin": "Hamburg-Altona",
"track": "8",
"detailsId": "78642%2F27599%2F82706%2F15139%2F80%3fstation_evaId%3D8000152"
}
, which is complete.
However, when I call the DEPARTUREboard information I get everything apart from the 'destination' JSON field.
{
"name": "ICE 272",
"type": "ICE",
"boardId": null,
"stopId": 8000152,
"stopName": "Hannover Hbf",
"dateTime": "2021-01-19T00:05",
"track": "7",
"detailsId": "972312%2F330581%2F159824%2F244192%2F80%3fstation_evaId%3D8000152"
}
, i.e., the 'destination' field is missing according to the Model schema
I guess this is a user error but I can't work out how to fix this!

Can we change the sequence of json items?

Can we change the sequence of json items?
For example:
[
{
"category": "Science: Mathematics",
"type": "multiple",
"difficulty": "medium",
"question": "In a complete graph G, which has 12 vertices, how many edges are there?",
"correct_answer": "66",
"incorrect_answers1": "67",
"incorrect_answers2 : "34",
"incorrect_answers3 : "11"
},
{
"category": "Science: Mathematics",
"type": "multiple",
"difficulty": "medium",
"question": "In base 2, what is 1 + 1?",
"incorrect_answers1": "2",
"incorrect_answers2 : "01",
"correct_answer": "10",
"incorrect_answers3 : "11"
},
{
"category": "Science: Mathematics",
"type": "multiple",
"difficulty": "medium",
"question": "In the hexadecimal system, what number comes after 9?",
"incorrect_answers1": "10",
"incorrect_answers2 : "The Number 0",
"correct_answer": "The Letter A",
"incorrect_answers3 : "16"
}
]
As mentioned in the comments that re-ordering JSON data is impossible and also not required.
For the current situation, you have to loop across the parent array containing the JSON objects, create a local array variable to get the list of re-ordered answers, push all the answers to this array and shuffle it using a library like lodash (https://lodash.com/docs/#shuffle) or a custom random functions, whatever works for your needs.
You can place this array within each object of this JSON while looping and give it a meaningful key like shuffled_answers.
So now your item structure will look like this:
{
"category": "Science: Mathematics",
"type": "multiple",
"difficulty": "medium",
"question": "In base 2, what is 1 + 1?",
"incorrect_answers1": "2",
"incorrect_answers2" : "01",
"correct_answer": "10",
"incorrect_answers3" : "11",
"shuffled_answers": ["2", "11", "10", "11"]
}
You can then use this array to display answer choices in your UI to ask user the question and use the correct_answer key to compare the correct answer from the user's choice.
I'm linking here a video tutorial for a very similar App developed in Vue using the above logic. You can refer for more insight about apps like these and use it for your requirements.
Hope that helps.

How to customize rest() route's description and id?

I configured Camel REST with Spring Boot and enabled actuator/camelroutes as in this example: https://github.com/apache/camel/blob/master/examples/camel-example-spring-boot/src/main/resources/application.properties
Now i am able to get my route descriptions... the problem is they are showing as route1,route2 etc, and provide no description which makes it difficult to distinguish which route belongs to which REST endpoint, e.g.
{
"id": "route2",
"uptime": "3.172 seconds",
"uptimeMillis": 3172,
"properties": {
"parent": "49889154",
"rest": "true",
"description": null,
"id": "route2"
},
"status": "Started"
}
Question is how do I provide custom description and id to rest() routes?
My route is simple:
rest("/hello")
.description("/hello GET endpoint")
.consumes("application/json").produces("text/html")
.get("/").description("Hello World example").outType(String.class)
.to("direct:hello")
and i tried adding .description after .rest("/bla") but it has no effect in the actuator/camelroutes
Ideally, i would like to get something like below:
{
"id": "route1",
"description": "direct hello route returning simple string",
"uptime": "3.173 seconds",
"uptimeMillis": 3173,
"properties": {
"parent": "76af51d6",
"rest": "false",
"description": "direct hello route returning simple string",
"id": "route1"
},
"status": "Started"
},
You need to set id and description to route context, not to rest context.
For example this definition:
rest("/hello")
.consumes("application/json").produces("text/html")
.get("/").outType(String.class)
.route().id("sayHi").description("This endpoint says Hi")
.to("direct:hello");
from("direct:hello")
.routeId("hello")
.setBody(constant("Hi"));
Generates this actuator output:
[
{
"id": "hello",
"uptime": "13.158 seconds",
"uptimeMillis": 13158,
"status": "Started"
},
{
"id": "sayHi",
"description": "This endpoint says Hi",
"uptime": "13.145 seconds",
"uptimeMillis": 13145,
"status": "Started"
}
]

Docusign REST API MERGE FIELD - SALESFORCE

Im trying to prefill my document with salesforcse Lead Name, however i cant accomplish it, the signHereTabs, and dateSignedTab is showing but the
texttabs dont get any data,
The REST API Documentation https://docs.docusign.com/esign/restapi/CustomTabs/CustomTabs/create/#request
says: that the row field is the "Specifies the row number in a Salesforce table that the merge field value corresponds to." but if i pass the salesforce record id im getting the error:
DocuSign Response{
"errorCode": "INVALID_REQUEST_PARAMETER",
"message": "The request contained at least one invalid parameter. int value expected for parameter: mergeField.row"
}
This is my json request:
{
"emailSubject": "Agreement",
"emailBlurb": "MSTSolutions is sending you this request for your electronic signature and enter or update confidential payment information.Please review and electronically sign by following the link below.",
"templateId": "42a4815d-f8ac-4972-b1ea-2e1534324658",
"envelopeIdStamping": "false",
"templateRoles": [{
"roleName": "Signer 1",
"name": "TEST TEST",
"email": "xxx#xxxx.com",
"recipientId": "1",
"tabs": {
"signHereTabs": [{
"xPosition": "25",
"yPosition": "50",
"documentId": "1",
"pageNumber": "1"
}],
"dateSignedTabs": [{
"name": "Date Signed",
"xPosition": "25",
"yPosition": "100",
"documentId": "1",
"pageNumber": "1"
}],
"textTabs": [{
"tabLabel": "LeadFirstName",
"xPosition": "25",
"yPosition": "200",
"documentId": "1",
"pageNumber": "1",
"mergeField": {
"configurationType":"Salesforce",
"path":"Lead",
"row":"00Q29000003fI13",
"writeback":"true",
"allowSenderToEdit":"true",
}
}]
}
}],
"status": "sent"
}
Thanks
Fairly sure the error is is how your path is configured. Try this:
"path": "Lead.FirstName"
and then remove the "Row" line
If you use the 'GET /v2/accounts/{accountId}/envelopes' create endpoint you can pass in the lead/opportunity/account Ids via the "Custom Fields" section. This will set all custom Salesforce fields you have defined in the template (relating to the SFIDs you provide) without having to set each tab one by one.
"customFields":{
"textCustomFields":[
{
"value":"0060n00000DIvfNAAT",
"name":"Opportunity",
"configurationType":"salesforce"
}
]
}
Note the textCustomFields is enclosed in a customFields block (which matches the published API) and most importantly, the configuration type must be set to "salesforce" and the Name must be "Opportunity" (etc) without the ##SF prefix which appears in a lot of examples on the web (for the SOAP api). By examining the 'GET /v2/accounts/{accountId}/envelopes/{envelopeId}/custom_fields' endpoint you can see that the API is automatically afixing the ##SF prefix and modifying the Value to include the record name:
{
"textCustomFields": [
{
"fieldId": "10140751586",
"name": "##SFOpportunity",
"show": "false",
"required": "false",
"value": "0060n00000DIvfNAAT~Test Opp Lisa Simpson"
}
}

Angular filteration issue

I have a json data which looks like this:
{
"id": 355,
"title": "ZISIMOPOULOS LTD",
"cat": "Contractor - High Pressure, Cutting & Breaking, Hydrodemolition, Surface Preparation - UHP, Tube, Pipe & Bundle Cleaning",
"catids": {
"1": 17,
"2": 18,
"3": 21,
"4": 26,
"5": 27
},
"link": "http://wja.dev/members/zisimopoulos-ltd/",
"memberType": "C1 - Water Jetting Contractor",
"email": "info#zisimopoulos.gr",
"telephone": "302104412004",
"fax": "302104416524",
"website": "www.zisimopoulos.gr",
"instructor": false
}
Each member has catids associated to it.
Now i need the filteration function, where on clicking on the categories in the left will list the member associated to that categories.
Filteration page layout
Thanks in advance.

Resources