I am getting below JSON object from sharepoint list. how can I get the value for Company in the Data operation ( select) for logic apps. I did item()['Company']?['Value'] and it is not working. Any suggestions?
"body": [
{
"Company": {
"#odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 0,
"Value": "Test1"
},
"Date From": "2022-03-30",
"Date To": "2022-03-31",
"Title": "Title 1"
},
{
"Company": {
"#odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
"Id": 2,
"Value": "Line2"
},
"Date From": "2022-03-21",
"Date To": "2022-03-29",
"Title": "Title 2"
}
]
}
I am fetching share-point list and then using data operations (select) to get the JSON as output.
I need JSON in the below format so that I can pass this to store proc and insert into the Azure SQL DB. I have another 12 items in the list.
[
{
"Company": "Test1",
"Date From": "2022-03-30",
"Date To": "2022-03-31",
"Title": "Title 1"
},
{
"Company": "Line2",
"Date From": "2022-03-21",
"Date To": "2022-03-29",
"Title": "Title 2"
}
]
Rather than select, you can set a variable. We're all different but that makes far more sense to me.
Your expression is much the same, I used ...
item()['Company']['Value']
Just make sure you initialise the variable outside and prior to the For each ...
This is the result for the first item in the array ...
To compile a full JSON object and add it to an array, again, simply use a variable and specify the values as need be.
Firstly, initialize your array outside of the For each ...
... and then in the For each, add an object to the array variable on each loop (make sure you include the quotes around the expression where required) ...
You just have to compile the JSON. The end result will look like this ...
This is the JSON in full ...
[
{
"Company": "Line2",
"Date From": "2022-03-21",
"Date To": "2022-03-29",
"Title": "Title 2"
},
{
"Company": "Test1",
"Date From": "2022-03-30",
"Date To": "2022-03-31",
"Title": "Title 1"
}
]
Also, you'll notice my list has come out in a different order, that's because the For each runs in parallel, if you need to avoid that, change the settings so it runs in a single thread ...
This is the JSON definition of the LogicApp, you can load it into your tenant and test with it ...
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"For_each": {
"actions": {
"Append_to_SQL_Array": {
"inputs": {
"name": "SQL Array",
"value": {
"Company": "#{item()['Company']['Value']}",
"Date From": "#{item()['Date From']}",
"Date To": "#{item()['Date To']}",
"Title": "#{item()['Title']}"
}
},
"runAfter": {},
"type": "AppendToArrayVariable"
}
},
"foreach": "#variables('SharePoint JSON')",
"runAfter": {
"Initialize_SQL_Array": [
"Succeeded"
]
},
"runtimeConfiguration": {
"concurrency": {
"repetitions": 1
}
},
"type": "Foreach"
},
"Initialize_SQL_Array": {
"inputs": {
"variables": [
{
"name": "SQL Array",
"type": "array"
}
]
},
"runAfter": {
"Initialize_SharePoint_JSON": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_SharePoint_JSON": {
"inputs": {
"variables": [
{
"name": "SharePoint JSON",
"type": "array",
"value": [
{
"Company": {
"Id": 0,
"Value": "Test1",
"odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
},
"Date From": "2022-03-30",
"Date To": "2022-03-31",
"Title": "Title 1"
},
{
"Company": {
"Id": 2,
"Value": "Line2",
"odata.type": "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference"
},
"Date From": "2022-03-21",
"Date To": "2022-03-29",
"Title": "Title 2"
}
]
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "Result",
"type": "array",
"value": "#variables('SQL Array')"
}
]
},
"runAfter": {
"For_each": [
"Succeeded"
]
},
"type": "InitializeVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"Recurrence": {
"evaluatedRecurrence": {
"frequency": "Month",
"interval": 12
},
"recurrence": {
"frequency": "Month",
"interval": 12
},
"type": "Recurrence"
}
}
},
"parameters": {}
}
I'm trying to loop through a multi-dimensional array to get properties of products that are part of line items. They look basically like this: (I did a json_encode so it would be easier to read)
[{
"rcpt": "email#email.com",
"vars": [{
"name": "SYSTEM",
"content": "Bikes"
}, {
"name": "CUSTOMERSERVICE",
"content": "(855-553-4889)"
}, {
"name": "IMAGE",
"content": "http:\/\/www.url.com\/assets\/images\/chicago\/email\/dear_member.jpg"
}, {
"name": "LINKCOLOR",
"content": "#3db7e4"
}, {
"name": "FACEBOOK",
"content": "Bikes"
}, {
"name": "TWITTER",
"content": "Bikes"
}, {
"name": "INSTAGRAM",
"content": "Bikes"
}, {
"name": "CLOSING",
"content": "Greetings"
}, {
"name": "item",
"content": [{
"lineItem": 1,
"id": "3",
"name": "24-Hour Pass Gift Certificate",
"quantity": 2,
"nameShort": "24-Hour",
"type": "Gift Certificate",
"image": "24hour_blank.jpg",
"price": "9.95",
"total": "19.90",
"taxable": false,
"giftCertificates": {
"3204": {
"id": "3204",
"redemptionNumber": "xxxxx",
"type": "24-Hour"
},
"3205": {
"id": "3205",
"redemptionNumber": "xxxxx",
"type": "24-Hour"
}
}
}, {
"lineItem": 2,
"id": "1",
"name": "Annual Membership Gift Certificate",
"quantity": 2,
"nameShort": "Annual",
"type": "Gift Certificate",
"image": "annual_blank.jpg",
"price": "75.00",
"total": "150.00",
"taxable": false,
"giftCertificates": {
"892": {
"id": "892",
"redemptionNumber": "xxxxxx",
"type": "Annual"
},
"893": {
"id": "893",
"redemptionNumber": "xxxxx",
"type": "Annual"
}
}
}]
}, {
"name": "orderID",
"content": 1220
}, {
"name": "giftMessage",
"content": false
}, {
"name": "email",
"content": "email#email.com"
}, {
"name": "transactionDate",
"content": "12\/23\/2015"
}, {
"name": "transactionTime",
"content": "12:21 pm"
}, {
"name": "salesTaxTotal",
"content": 0
}, {
"name": "salesTaxRatePercent",
"content": "6.250"
}, {
"name": "TransactionAmount",
"content": "169.90"
}, {
"name": "account_number",
"content": "XXXX1111"
}, {
"name": "card_type",
"content": "Visa"
}, {
"name": "firstName",
"content": "tetete"
}, {
"name": "lastName",
"content": "tethuhhu"
}, {
"name": "address",
"content": "295 Place St"
}, {
"name": "city",
"content": "Brooklyn"
}, {
"name": "state",
"content": "NY"
}, {
"name": "zip",
"content": "11238"
}, {
"name": "country",
"content": "US"
}, {
"name": "phone",
"content": "8888888888"
}, {
"name": "transactionId",
"content": "xxxxxx"
}, {
"name": "shipToFirstName",
"content": "tetete"
}, {
"name": "shipToLastName",
"content": "tethuhhu"
}, {
"name": "shipToAaddress",
"content": "295 Place St"
}, {
"name": "shipToCity",
"content": "Brooklyn"
}, {
"name": "shipToState",
"content": "NY"
}, {
"name": "shipToZipCode",
"content": "11238"
}, {
"name": "ShipToCountry",
"content": "US"
}, {
"name": "ShipToCountry",
"content": "US"
}]
}]
So I am trying to get a print out of each gift certificate's type and redemption number. When I iterate through {{ giftCertificates }} like this:
{{#each giftCertificates}}
{{type}} {{redemptionNumber}}
{{/each}}
I get one of the line items but not the other. I'm guessing maybe it is being overwritten when it loops through again? But I have also tried to loop through {{ item }} and grab {{ giftCertificates.type }} and {{ giftCertificates.redemptionNumber }} and that does not work either. What is the correct way to get all of these from each line item?
Thanks for your help.
I know this is a very old question, but:
you can use {{this.proprietyName}} to get the type and number:
{{#each giftCertificates}}
{{this.892.type}}
{{/each}}
do not forget to add this to the mandrill message o
"merge": true,
"merge_language": "handlebars",
Also, the data structure is not ideal:
giftCertificates[
{
"id": "892",
"redemptionNumber": "xxxxxx",
"type": "Annual"
},
{
"id": "893",
"redemptionNumber": "xxxxxx",
"type": "Annual"
}
]
would be easier to handle.
The error i am getting is this : Can't parse fields attribute. Is it a JSON array or CSV list?
The problem is in the select menu which is being included in the form. what i want to achieve is a select box as shown here on this link : Registration plugin
But somehow the problem is that the select box is not being displayed!
<iframe src='http://www.facebook.com/plugins/registration.php?
client_id=325340244194060&
redirect_uri=http://www.pingcampus.com/facebook_registration_plugin/store_user_data.php&
fields=[
{"name":"name"},
{"name":"email"},
{"name":"gender"},
{"name":"birthday"},
{'name':'captain', 'description':'Best Captain', 'type':'select', 'options':{'P':'Jean-Luc Picard','K':'James T. Kirk'}}
{'name':'captain', 'description':'College','type':'select','options':
{'P':'Jean-Luc Picard','K':'James T. Kirk',
'1':'Acropolis','2':'Astral','3':'Aurobindo','4':'BM','5':'Central','6':'Chameli','7':'IET (DAVV)','8':'IIST
','9':'IIST2
','10':'IPS
','11':'JDCT
','12':'KCB
','13':'LKCT
','14':'LNCT
','15':'MIT (Malwa)
','16':'Malwa (Malwa2)
','17':'Mandsaur
','18':'Mathuradevi
','19':'MITM (Medi1)
','20':'MIST (Medi2)
','21':'MGIEM
','22':'Nalin
','23':'Oriental
','24':'Patel
','25':'Prestige
','26':'Priyatam
','27':'Rishiraj
','28':'RKDF
','29':'Royal
','30':'Sanghvi
','31':'Sdbansal
','32':'SGSITS
','33':'SIMS
','34':'SKSITS
','35':'Star
','36':'SVCE
','37':'SVITS
','38':'Transnational
','39':'Truba
','40':'Venkateshwar
','41':'Vidhyasagar
','42':'Vikrant
','43':'Vindhya
','#':'--------------------------------
','#':'Commerce
','#':'--------------------------------
','44':'Acro
','45':'Apex
','46':'Arihant
','47':'BM
','48':'Chamelidevi
','49':'Chimc
','50':'Choithram
','51':'Christian
','52':'DCBS (Daly College)
','53':'IBMR
','54':'IIMR (IIST)
','55':'IIPS (DAVV)
','56':'Ilva
','57':'IMIR
','58':'Imperial
','59':'IMS (DAVV)
','60':'Islamia
','61':'JDCT
','62':'LKCT
','63':'LNCT
','64':'Maharaja
','65':'MIT (Malwa)
','66':'Mathuradevi
','67':'Matushri
','68':'MBKhalsa
','69':'Medicaps
','70':'Patel
','71':'Pioneer
','72':'Prestige
','73':'Priyatam
','74':'Renaissance
','75':'Rishiraj
','76':'Sahib
','77':'SAIMS
','78':'Sanghvi Innovative
','79':'Sapient
','80':'SGSITS
','81':'SIMS
','82':'SJDM
','83':'SKSITS
','84':'Softvision
','85':'SVCE
','86':'Rransnational
','87':'Vaishnav
','88':'Venkteshwar
','89':'Vidhyasagar
','90':'Vikrant
','#':'--------------------------------
','#':'Pharmacy
','#':'--------------------------------
','91':'Acropolis
','92':'Aurobindo
','93':'BM
','94':'Central
','95':'SOPE (DAVV)
','96':'IIP(IIST)
','97':'IPS
','98':'Oriental
','99':'Rishiraj
','100':'RKDF
','101':'Safe
','102':'SGSITS
','103':'Smriti (SCOPE)
','104':'svce
','105':'vikrant
','#':'--------------------------------
','#':'Medical
','#':'--------------------------------
','106':'Arihant
','107':'Bombay Hospital
','108':'Index
','109':'MGMMC
','110':'RD Memorial
','111':'Shubhdeep
','#':'--------------------------------
','#':'Dental
','#':'--------------------------------
','112':'Aurobindo
','113':'CDSH
','114':'GCD
','115':'Index
','116':'Modern
','#':'--------------------------------
','#':'Arts
','#':'--------------------------------
','117':'BIG Aims
','118':'Frameboxx
','119':'INIFD
','120':'MAAC
','121':'SDPS
','122':'SJMC (DAVV)
','123':'Virtual Voyage
','124':'Zica
','132':'EMRC (DAVV)
','#':'--------------------------------
','#':'Architecture
','#':'--------------------------------
','125':'IPS
','126':'SDPS
','#':'--------------------------------
','#':'Law
','#':'--------------------------------
','127':'Christian
','128':'SOL(DAVV)
','129':'IIL
','130':'Vaishnav'} },
{"name":"Arts","description":"Arts","type":"checkbox","value":"Arts"},
{"name":"Act","description":"Act","type":"checkbox","value":"Act"},
{"name":"Cooking","description":"Cooking","type":"checkbox","value":"Cooking"},
{"name":"Dance","description":"Dance","type":"checkbox","value":"Dance"},
{"name":"Designing","description":"Designing","type":"checkbox","value":"Designing"},
{"name":"Fashion","description":"Fashion Designing","type":"checkbox","value":"Fashion Designing"},
{"name":"Interior","description":"Interior Designing","type":"checkbox","value":"Interior Designing"},
{"name":"Modeling","description":"Modeling","type":"checkbox","value":"Modeling"},
{"name":"Photography","description":"Photography","type":"checkbox","value":"Photography"},
{"name":"Poetry","description":"Poetry / Writing","type":"checkbox","value":"Poetry / Writing"},
{"name":"Programming","description":"Programming","type":"checkbox","value":"Programming"},
{"name":"Reading","description":"Reading","type":"checkbox","value":"Reading"},
{"name":"Sketching","description":"Sketching / Drawing","type":"checkbox","value":"Sketching / Drawing"},
{"name":"Singing","description":"Singing","type":"checkbox","value":"Singing"},
{"name":"Sports","description":"Sports","type":"checkbox","value":"Sports"},
{"name":"Stunting","description":"Stunting","type":"checkbox","value":"Stunting"},
{"name":"Videography","description":"Checkthis","type":"checkbox","value":"Videography"},
{"name":"Other","description":"Other","type":"checkbox","value":"Other"},
{"name":"captcha"}
]'
scrolling="auto"
frameborder="no"
style="border:none"
allowTransparency="true"
width="500"
height="800"
>
</iframe>
Try to replace fields=[....] with valid JSON
[
{
"name": "name"
},
{
"name": "email"
},
{
"name": "gender"
},
{
"name": "birthday"
},
{
"name": "captain",
"description": "BestCaptain",
"type": "select",
"options": {
"P": "Jean-LucPicard",
"K": "JamesT.Kirk"
}
},
{
"name": "captain",
"description": "College",
"type": "select",
"options": {
"1": "Acropolis",
"2": "Astral",
"3": "Aurobindo",
"4": "BM",
"5": "Central",
"6": "Chameli",
"7": "IET(DAVV)",
"8": "IIST",
"9": "IIST2",
"10": "IPS",
"11": "JDCT",
"12": "KCB",
"13": "LKCT",
"14": "LNCT",
"15": "MIT(Malwa)",
"16": "Malwa(Malwa2)",
"17": "Mandsaur",
"18": "Mathuradevi",
"19": "MITM(Medi1)",
"20": "MIST(Medi2)",
"21": "MGIEM",
"22": "Nalin",
"23": "Oriental",
"24": "Patel",
"25": "Prestige",
"26": "Priyatam",
"27": "Rishiraj",
"28": "RKDF",
"29": "Royal",
"30": "Sanghvi",
"31": "Sdbansal",
"32": "SGSITS",
"33": "SIMS",
"34": "SKSITS",
"35": "Star",
"36": "SVCE",
"37": "SVITS",
"38": "Transnational",
"39": "Truba",
"40": "Venkateshwar",
"41": "Vidhyasagar",
"42": "Vikrant",
"43": "Vindhya",
"44": "Acro",
"45": "Apex",
"46": "Arihant",
"47": "BM",
"48": "Chamelidevi",
"49": "Chimc",
"50": "Choithram",
"51": "Christian",
"52": "DCBS(DalyCollege)",
"53": "IBMR",
"54": "IIMR(IIST)",
"55": "IIPS(DAVV)",
"56": "Ilva",
"57": "IMIR",
"58": "Imperial",
"59": "IMS(DAVV)",
"60": "Islamia",
"61": "JDCT",
"62": "LKCT",
"63": "LNCT",
"64": "Maharaja",
"65": "MIT(Malwa)",
"66": "Mathuradevi",
"67": "Matushri",
"68": "MBKhalsa",
"69": "Medicaps",
"70": "Patel",
"71": "Pioneer",
"72": "Prestige",
"73": "Priyatam",
"74": "Renaissance",
"75": "Rishiraj",
"76": "Sahib",
"77": "SAIMS",
"78": "SanghviInnovative",
"79": "Sapient",
"80": "SGSITS",
"81": "SIMS",
"82": "SJDM",
"83": "SKSITS",
"84": "Softvision",
"85": "SVCE",
"86": "Rransnational",
"87": "Vaishnav",
"88": "Venkteshwar",
"89": "Vidhyasagar",
"90": "Vikrant",
"91": "Acropolis",
"92": "Aurobindo",
"93": "BM",
"94": "Central",
"95": "SOPE(DAVV)",
"96": "IIP(IIST)",
"97": "IPS",
"98": "Oriental",
"99": "Rishiraj",
"100": "RKDF",
"101": "Safe",
"102": "SGSITS",
"103": "Smriti(SCOPE)",
"104": "svce",
"105": "vikrant",
"106": "Arihant",
"107": "BombayHospital",
"108": "Index",
"109": "MGMMC",
"110": "RDMemorial",
"111": "Shubhdeep",
"112": "Aurobindo",
"113": "CDSH",
"114": "GCD",
"115": "Index",
"116": "Modern",
"117": "BIGAims",
"118": "Frameboxx",
"119": "INIFD",
"120": "MAAC",
"121": "SDPS",
"122": "SJMC(DAVV)",
"123": "VirtualVoyage",
"124": "Zica",
"125": "IPS",
"126": "SDPS",
"127": "Christian",
"128": "SOL(DAVV)",
"129": "IIL",
"130": "Vaishnav",
"132": "EMRC(DAVV)",
"P": "Jean-LucPicard",
"K": "JamesT.Kirk",
"#": "--------------------------------"
}
},
{
"name": "Arts",
"description": "Arts",
"type": "checkbox",
"value": "Arts"
},
{
"name": "Act",
"description": "Act",
"type": "checkbox",
"value": "Act"
},
{
"name": "Cooking",
"description": "Cooking",
"type": "checkbox",
"value": "Cooking"
},
{
"name": "Dance",
"description": "Dance",
"type": "checkbox",
"value": "Dance"
},
{
"name": "Designing",
"description": "Designing",
"type": "checkbox",
"value": "Designing"
},
{
"name": "Fashion",
"description": "Fashion Designing",
"type": "checkbox",
"value": "Fashion Designing"
},
{
"name": "Interior",
"description": "Interior Designing",
"type": "checkbox",
"value": "Interior Designing"
},
{
"name": "Modeling",
"description": "Modeling",
"type": "checkbox",
"value": "Modeling"
},
{
"name": "Photography",
"description": "Photography",
"type": "checkbox",
"value": "Photography"
},
{
"name": "Poetry",
"description": "Poetry / Writing",
"type": "checkbox",
"value": "Poetry / Writing"
},
{
"name": "Programming",
"description": "Programming",
"type": "checkbox",
"value": "Programming"
},
{
"name": "Reading",
"description": "Reading",
"type": "checkbox",
"value": "Reading"
},
{
"name": "Sketching",
"description": "Sketching / Drawing",
"type": "checkbox",
"value": "Sketching / Drawing"
},
{
"name": "Singing",
"description": "Singing",
"type": "checkbox",
"value": "Singing"
},
{
"name": "Sports",
"description": "Sports",
"type": "checkbox",
"value": "Sports"
},
{
"name": "Stunting",
"description": "Stunting",
"type": "checkbox",
"value": "Stunting"
},
{
"name": "Videography",
"description": "Checkthis",
"type": "checkbox",
"value": "Videography"
},
{
"name": "Other",
"description": "Other",
"type": "checkbox",
"value": "Other"
},
{
"name": "captcha"
}
]
Your fields parameter for Registration social plugin contain not valid JSON object (JSON should use double quotes instead of single quotes) and you're missing , (comma) in the middle of array, after next line:
{'name':'captain', 'description':'Best Captain', 'type':'select', 'options':{'P':'Jean-Luc Picard','K':'James T. Kirk'}}
Update:
Actually even usage of just valid JSON may not work in that case due to fact that this is passed as query string arguments, so that JSON should be properly encoded to avoid problems. Also may cause some issues.
Also you have two fields named "captain" (which cause problem with registration plugin too).
Here I've created some samples (due to massive code of fields, I'm not putting them here):
Creating fields from JavaScript object and passing em to Registration plugin: http://jsfiddle.net/QwdCv/
Correctly encoded fields in URL passed directly within iframe tag src attribute: http://jsfiddle.net/QwdCv/1/