cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
arturdjali
Helper I
Helper I

Creating a lookup column in a list

Hi All,

 

i am trying to create a lookup column for a new list i am creating using the http request. I believe i've got most of it setup but im not sure on the json need to all for multiple fields in this case ID and essionDuration.

 

This is the column i'm trying to replace in flow:

arturdjali_0-1655467654689.png

 

this is how it looks in the flow:

arturdjali_1-1655467757049.png

 

any help is appreciated.

 

thank you 

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Super User
Super User

Hi @arturdjali,

 

You can use the FieldRef property in two other requests with the same CreateFieldAs Xml method. You can reuse the Id from the output of your first request to reference the lookup field in your second and third request.

 

Below is an example.

{"parameters":{"__metadata":{"type":"SP.XmlSchemaFieldCreationInformation"},"SchemaXml":"<Field DisplayName='Course: ID' FieldRef='@{body('Send_an_HTTP_request_to_SharePoint')['d']['Id']}' Format='Dropdown' IsModern='TRUE' List='@{variables('LookupListGUID')}' Name='Course: ID' ShowField='ID' Title='Course: ID' Type='Lookup'></Field>"}}

 

createfieldasxml_relatedcolumns.png

 

View solution in original post

4 REPLIES 4
Expiscornovus
Super User
Super User

Hi @arturdjali,

 

You could use the CreateFieldAsXml method for the creation of a lookup field. 

 

Try something like below:

 

{"parameters":{"__metadata":{"type":"SP.XmlSchemaFieldCreationInformation"},"SchemaXml":"<Field DisplayName='Course' Format='Dropdown' Indexed='FALSE' IsModern='TRUE' IsRelationship='FALSE' List='@{variables('LookupListGUID')}' Name='Course' ShowField='Title' Title='Course' Type='Lookup'></Field>","Options":12}}

 

createlookupfield.PNG

Hi @Expiscornovus ,

 

This works perfectly for creating the lookup column, my only other question what change would i need to make to select columns to show ID and SessionDuration?

 

arturdjali_0-1655720667052.png

Thank you

Expiscornovus
Super User
Super User

Hi @arturdjali,

 

You can use the FieldRef property in two other requests with the same CreateFieldAs Xml method. You can reuse the Id from the output of your first request to reference the lookup field in your second and third request.

 

Below is an example.

{"parameters":{"__metadata":{"type":"SP.XmlSchemaFieldCreationInformation"},"SchemaXml":"<Field DisplayName='Course: ID' FieldRef='@{body('Send_an_HTTP_request_to_SharePoint')['d']['Id']}' Format='Dropdown' IsModern='TRUE' List='@{variables('LookupListGUID')}' Name='Course: ID' ShowField='ID' Title='Course: ID' Type='Lookup'></Field>"}}

 

createfieldasxml_relatedcolumns.png

 

@Expiscornovus  Thank you! That does the trick.

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

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

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (3,114)