cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
iskguy
Helper III
Helper III

Daily CSV to SharePoint

I have done this before and it has work, but with this new work flow I do not know why.  I have the following section from the automate job

iskguy_0-1644420121830.png

 

The CSV is demographic information (I cannot post a sample due to PHI data) with first name, last name, address, etc etc etc, nothing out of the ordinary.  It is generated from a SQL server procedure and is delivered to a share every morning.  And the file share it is saved to is the trigger for this flow.  All I need to do is parse this csv and create new SharePoint list items.

 

The newLine is a regular CRLF.  splitByLines is split(body('Get_file_content'),outputs('newLine')).  fieldNames is split(first(outputs('splitByLines')),',').  Select is skip(outputs('splitByLines'),1) and lists all the 17 fields except for the last one and then the Select Item is split(item(),',')?[0] <-- or whatever index it happens to be.  SampleData was used to get the JSON structure.

 

This is the JSON schema.  When I add the action to create an item to SharePoint, the ONLY things that are listed for the options for the fields in the list (from JSON) are: item, body, and the one field that is the key, "clientid"...no other fields can be mapped.  

 

I appreciate any help.  I am hoping it is something simple.

 

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "clientid": {
                "type": "string"
            },
            "firstname": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "lastname": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "middlename": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "dob": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "city": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "state": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "zip": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "sex": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "ssn": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "RaceName1": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "RaceCode1": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "RaceName2": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "RaceCode2": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "RaceName3": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "RaceCode3": {
                "type": [
                    "string",
                    "null"
                ]
            },
            "HispanicOriginCode": {
                "type": [
                    "string",
                    "null"
                ]
            }
        },
        "required": [
            "clientid",
            "firstname",
            "lastname",
            "middlename",
            "dob",
            "city",
            "state",
            "zip",
            "sex",
            "ssn",
            "RaceName1",
            "RaceCode1",
            "RaceName2",
            "RaceCode2",
            "RaceName3",
            "RaceCode3",
            "HispanicOriginCode"
        ]
    }
}

 

1 ACCEPTED SOLUTION

Accepted Solutions
jinivthakkar
Super User
Super User

@iskguy this is how you can get everything inside properties, the below example shows how to get value from lastname, I pasted your JSON in a compose, hence I used compose_2 in below expression but you need to use output which gives you JSON

 

outputs('Compose_2')?['items']?['properties']?['lastname']['type'][0]
 
Use this expression to get everything from required, below examples shows how to get client ID
 
outputs('Compose_2')?['items']['required'][0]
 

--------------------------------------------------------------------------------

If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

 

View solution in original post

5 REPLIES 5
jinivthakkar
Super User
Super User

@iskguy this is how you can get everything inside properties, the below example shows how to get value from lastname, I pasted your JSON in a compose, hence I used compose_2 in below expression but you need to use output which gives you JSON

 

outputs('Compose_2')?['items']?['properties']?['lastname']['type'][0]
 
Use this expression to get everything from required, below examples shows how to get client ID
 
outputs('Compose_2')?['items']['required'][0]
 

--------------------------------------------------------------------------------

If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

 

Thanks!  I will try this out.

Sadly I just ran it and as it did run for nearly an hour, I was thinking it would work, but all data was blank.  So I am still not sure what is going on

jinivthakkar
Super User
Super User

@iskguy create a new test flow, trigger manual, compose action then paste your JSON in compose, take another action and paste the expression given above, if it works in test flow, it has to work in your flow also 

Try this out

Thank you again.  I did try something as I noticed that the customerid value was the only field that could be mapped.  I removed the "null" from the types and they did appear so I could map them to the same fields in the SharePoint list.  After, I re-added the "null" and it is working

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (3,060)