I am new to Logic Apps and trying to get a good understanding of it by getting hands on and reading. I have created a few apps now and it is making more sense each time. The problem i am having is that i can create a new Dynamics record in one action, retrieve the primary key it generated in another action. But how do i use this primary value in another action to create a related record in another action. There doesn't seem to be away to store or assign variables or modify parameters on the fly?
Variables for Logic Apps have now been released, as of 24th March 2017. However they only currently support integers and floats, and you can only initialize or increment them. Support for string variables, and modifying them after initialization will be coming soon. You can create them via the new Variable action.
variables are now supported in logic app, they are available in actions, first you need to initialize your variable(currently supported types are Boolean, Integer, String, Float, object, Array) and perform the desired actions on them and also modify them.
You can use "type": "Compose" in an action to set a variable eg:
"IsMissing": {
"type": "Compose",
"inputs": {
"what": "Something is missing"
},
"runAfter": {}
}
}
then use body('IsMissing') to use this variable.
Let us assume that your logic app action for creating Dynamics Record is "CreateRecord". And it produces an output like this
{
"primarykey" : "<guid>"
}
You can access the output of this action like this
#body('CreateRecord').primarykey
OR
#body('CreateRecord')['primarykey']
Variables are not currently supported in Logic Apps.
Related
I am currently looking to build out an event driven EventBridge event module (as opposed to a scheduled one, for example) for usage in our IaaC portfolio. The example code below shows how the normal event JSON pattern would look. I can obviously add a normal single variable for the "detail-type" and the "source", but can someone advise on a way to create some kind of single mapped variable that I could pass one or more parameters for the "detail" map?
event_pattern = <<PATTERN
{
"detail-type": ["Glue Job State Change"],
"source": ["aws.glue"],
"detail": {
"jobName": ["${var.env}_${var.department}_gluejob_${var.pipeline}_publish-small", "${var.env}_${var.department}_gluejob_${var.pipeline}_catalog", "${var.env}_${var.department}_gluejob_${var.pipeline}_publish-large", "${var.env}_${var.department}_gluejob_${var.pipeline}_notify"],
"state": ["FAILED"]
}
}
The need for this is that across a number of different services we may need any number of key and value parameters in "details" so some way to pass in a map which can have any number of key value pairs would be ideal. Now if this wasn't json I could use a dynamic value in TF but I am unsure what to do here with it being an inline JSON pattern.
I should also mention before someone suggests it, that I have currently just done the work around of having the event pattern passed as variable and using data and a template json.tpl file that can pass the pattern for each resource in individually for each usage of the module, but would like to know if anyone can advise on the solution I was hoping was possible above?
Any advice would be greatly appreciated!
I am parsing an XML document to JSON, and eventhough I have the type array declared in the json schema, if there is just one element in the array it gets transformed into an objet like this.
"ListOfCodes":{"Codes":{{"Code":"111"}}}
but I need this:
"ListOfCodes":{"Codes":[{"Code":"111"}]}
I have several arrays in the document and I only get the sqare brackets when there is a multiple array.
and adding the properties manually is not an option.
Anyone know what can i modify to fix this in the logic app?
Unfortunately, there isn't a good solution for us to implement this requirement in logic app. Here is another post which is similar to your problem. To implement the requirement, we can just:
1. Use the "Compose" action to generate the object by hand (manually put all the properties and arrays where they need, potentially using the #array() action.
2. Call an Azure Function or some external code that can more specifically craft a valid JSON.
I also try to test it in some other way, such as use json:Array="true" and use <?xml-multiple?> but they all fail in logic app. So I think the only above two solutions(mentioned in that post) can be used. Neither approach is good, though.
I am trying to implement undo/redo in a complex application
This is how my history array looks.
[
{
action:“added”,
payload:{
id:"32132132",
data: "JSON.Stringify(JSON.parse(data))) initial data getting from initial app setup"
}
},
{
action:“updated”,
payload:{
id:"32132132",
data: "getting the diff"
}
},
{
action:“deleted”,
payload:{
id:"32132132",
data: "data"
}
}
]
As far as I understood, the undo, redo works on a history index,
which will be changed based on undo (increment pointer) , redo (decrement pointer) concept.
Based on this approach I am calling a mutation where
apply(state,actiontype){
if(actiontype==undo){
remove the respective objects
pop(data) //pops the data out of other places in the application not the history
historyindex++;
}else if(actiontype==redo){
get the data from history
unshift(data);
historyindex–-;
}
}
I feel this is not the most efficient way to perform undo/redo operations, as it includes cloning objects and even it has to handle huge sets of data. Which might lead to freezing of the application I am still a newbie in vuejs, please do correct me if I am wrong, is there any more efficient way to perform undo-redo operations ? or the right way to implement undo/redo in vuejs?.
Any suggestions would be helpful
You should consider use some kind of data compress (like git does), with this you can continue using only the Vuex. Otherwise, consider use some local database as already recommended ;D
you may want to connect your app to any simple database that store your previous object try firebase if it has no backend and make vuex just have the previous value but older ones saved to the firebase database by the mutation method in vuex
I'm in the learning process of the MEAN stack and I'm using meanjs.org as a starting point and used it to generate scaffolding for a new object.
I'm trying to figure out how to implement the correct pattern in the client Angular code in addition to the server code.
Assume I have a collection of meetings and each meeting contains an array of participant objects (by reference, not embedded).
Therefore my javascript object may look like this:
meeting: {
_id: 123456,
location: "Room 222",
startDatetime: ....,
endDatetime: ....,
participants: [
{ _id: 33333 },
{ _id: 44444 }
]
}
If I wanted to add a participant (and assuming I have the id of that new participant), I could implement this in various ways:
In an angular controller handle the addition to the participants array and just "push" the new id onto the array. Then called the typical REST update api (in the mean stack a service/ng-resource) to handle to the update. Then on the server (mongoose) be able to handle this by taking the added entry in the array and call the appropriate function to add a participant.
Have a separate REST function to handle adding a participant and implement similar to #1.
Some other way that keeps things simple and clean.
What is the recommended way (recommended from the MEAN architecture or from a RESTful architecture or from a mongoose/MongoDB perspective) to implement this?
I don't think there is only one right answer to this question. Assuming that you will add participants more often than you will edit the rest of the data for a meeting, like location and start time, I would add a separate node endpoint that just adds participants for a given meeting id. Then I'd use $addToSet to add them to Mongo, with $each for multiple participants.
On the angular side, I'd create an angular service that makes the $resource call to the node server, passing in just the new participants and the meeting id. My angular controller would call the angular service to save the new participant.
I am designing a web service accepting POST requests with JSON in the message body. I want the requestor to be able to specify multiple values for a parameter, but also single values.
So, for simple cases I support JSON like:
{
"name" : "value"
}
And, in more complex cases, I also support JSON like:
{
"name" : [
"value one",
"value two",
"value three"
]
}
My question is: is this an abnormal interface for a Web Service? Am I overcomplicating things here?
The alternative would be, as I want to support arrays of values, to require arrays of values, even for the simple case:
{
"name" : [
"value"
]
}
I don't like this but want to get the community's input before making a decision.
EDIT:
I removed the word REST from the conversation as that factor isn't really important here.
It is typical of a web service to accept an array of values for a POST request. However, the number of elements may be zero or many. Keeping it as an array of values, even if only one value is going in, is going to keep things simple and consistent.
If a user of the web service needs to submit a single element for creation or modification (upsert), then perhaps a PUT request would be more appropriate.
I will prefer a single structure for both cases and then there will be only one processing logic to code and no need for special case to decide on.
Also this is not much of REST related. It is more of on trading off on the the processing or handling of the data v.s. whatever reasons that drive you to think of splitting the data into two forms in the first place.
Hope this help.
REST is about resources and their representations. So ask yourself:
What resource does the JSON represent?
Can you answer this question?
From the JSON in your question I would say, the resource is an object that has names
. It is not an object that has one name.
So I recommend to use your second approach.