cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ShriramP
Helper II
Helper II

SharePoint Content Types in PowerApps Form - A Workaround!

Microsoft has not yet provided support to handle SharePoint List Content Types through Power Apps. There is still one idea "under review" to Microsoft.

 

SharePoint Modern OOB List form already supports handling of multiple Content Type forms. But if we want to have Customized view of the SharePoint form then Power Apps doesn't support it yet. And though InfoPath support's it in SharePoint Online, this product is approaching end of its lifecycle.

 

So, to make it working in Power Apps (similar like SharePoint Modern OOB List Form), here is a custom workaround.

 

Please follow the steps one by one as mentioned below. Please note, these steps expect you to have intermediate level of expertise in Power Apps and Modern SharePoint Online.


SharePoint Modern List Configuration

 

- Create modern list named "test" in any of your test site collection.
- In List Advanced Settings, Allow management of content types.
- Add one more existing content type as "Comment" to the List (along with default Item content type)
- Assign default value “hello” to OOB Title column
- Add non-mandatory single text column "CustomContentType" for storing Content Type value (add to all content types, add to default view).
- Add 3 (non-mandatory) single text columns TestColumn1, TestColumn2, TestColumn3 (add to all content types, add to default view).


(The reason that we need to have all columns as non-mandatory columns in SharePoint is that OOB SharePoint save action will not be execute if other Content Type Power Apps forms have mandatory columns. Instead we can make needed fields as mandatory in Power Apps)

- These 4 new columns will be visible in both "Item" and "Comment" List content type
- Remove "TestColumn2" and "TestColumn3" column from Item List Content Type
- Remove "TestColumn1" column from Comment List Content Type

 

1.jpg
- Open the OOB List new form (of Item Content Type) and Customize the form in Power Apps


2.jpg


Power Apps Configuration

 

Configuring Screens:
- Now in Power Apps, Create Duplicate Screen of default screen. Duplicate screen form will have same data source.
- Rename the Screens to "ContentTypeSPScreen1" and "ContentTypeSPScreen2" respectively.
- Set formula on "ContentTypeSPScreen1" screen OnVisible property
Set(varScreenVisible, "1");

- Set formula on "ContentTypeSPScreen2" screen OnVisible property
Set(varScreenVisible, "2");

 

Configuring Forms:

- Rename the Forms to "ContentTypeSPForm1" and "ContentTypeSPForm2" respectively
- Set both forms default mode as "New"
- In Forms, Add needed fields of respective OOB content type onto the form:
- Add Title, TestColumn1 and CustomContentType in Item Form "ContentTypeSPForm1"
- Add Title, TestColumn2, TestColumn3 and CustomContentType in Comment Form "ContentTypeSPForm2"
- In "ContentTypeSPForm2" form, make “TestColumn2” as mandatory by Setting "TestColumn2" field "Required" property as true.


3.jpg

- In CustomContentType field in "ContentTypeSPForm1" form, Set "Update" value as "ddCT1.Selected.CTValue" and Visible as "false".
- In CustomContentType field in "ContentTypeSPForm2" form, Set "Update" value as "ddCT2.Selected.CTValue" and Visible as "false".

Configuring App OnStart event:
- In App "OnStart" event add this code


Collect( ContentTypeList,

{

CTId: 1,

CTValue: "Item"

},

{

CTId: 2,

CTValue: "Comment"

}

); Set (varScreenVisible, "1"); Navigate(ContentTypeSPScreen1,ScreenTransition.Fade);


Configuring dropdown control in "ContentTypeSPScreen1" screen:

- Add new label lblCT1 and dropdown ddCT1 controls to screen "ContentTypeSPScreen1".
- Assign dropdown data source as "ContentTypeList" and assign Value as CTValue.
- Set "Item" text to "Default" property of "ddCT1" dropdown control
- Set varResetddCT1 to "Reset" property of "ddCT1" dropdown control
- Apply formula on ddCT1 "onChange" event:
If(ddCT1.Selected.CTId = 2, Set(varResetddCT2,true); Navigate(ContentTypeSPScreen2,ScreenTransition.Fade));

Configuring dropdown control in "ContentTypeSPScreen2" screen:

- Add new label lblCT2 and dropdown ddCT2 controls to screen "ContentTypeSPScreen2".
- Assign dropdown data source as "ContentTypeList" and assign Value as CTValue.
- Set "Comment" text to "Default" property of "ddCT2" dropdown control
- Set varResetddCT2 variable to "Reset" property of "ddCT2" dropdown control
- Apply formula on ddCT2 "onChange" event:
If(ddCT2.Selected.CTId = 1, Set(varResetddCT1,true); Navigate(ContentTypeSPScreen1,ScreenTransition.Fade));

Form controls should look like this:

 

4.jpg

Configuring "SharePointIntegration":

- In SharePointIntegration, Update formula in advanced events carefully as mentioned in screen shot below:

 

5.jpg

Publish Power Apps:

- Save Power Apps and Publish to SharePoint

Test in SharePoint List:

- Now in SharePoint List, you can select any Content Type from OOB New Item dropdown. This doesn't matter as we will select actual content type from our new Custom Power Apps Form.


6.jpg

 


- Now try saving "Item" Content Type form

 

7.jpg

- Also try "Comment" Content Type form


8.jpg

- It should show items in list as below
9.jpg

Note: This example is for "New" form. For Edit form, you can duplicate screens plus forms and make its default mode as "Edit" and then you can apply some custom logic based on "CustomContentType" field to edit particular Content Type form in Power Apps. Also here we considered only 2 content types to give you an idea how it can be done in Power Apps, but you may have multiple content types and logic can be replicated to those in a similar way like mentioned in this article.


Happy Learning, Anywhere! 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
ShriramP
Helper II
Helper II

Consider above article as a solution to SharePoint Content Type in PowerApps workaround topic!

View solution in original post

16 REPLIES 16
v-jefferni
Community Support
Community Support

Hi @ShriramP ,

 

Thanks a lot for sharing this!

 

Please consider reply your original post and mark it as a solution to help other users find this.

 

Best regards,

Community Support Team _ Jeffer Ni

Community Support Team _ Jeffer Ni

If this post helps, then please consider Accept it as the solution to help the other members find it.

ShriramP
Helper II
Helper II

Consider above article as a solution to SharePoint Content Type in PowerApps workaround topic!

Thanks @v-jefferni !

 

I will surely do so!

lmdiorio
Frequent Visitor

I followed all the steps but it doesn't work when custom content type is Document Set.  Anyone have a solution for having a PowerApps form when using Document Set.  The error is below when attempting to save.

lmdiorio_0-1658814080969.png

 

ICPAaron
Frequent Visitor

Where is the crucial step in these directions that tells SharePoint to use the custom Power Apps form? I know how to create a custom form in Power Apps and how to work with content types, but I do not understand how to tell SharePoint to use the custom form. Please advise.

To clarify, I created a custom content type called "Contractor" and selected Document Set as the parent.  I can edit an existing item with my PowerApps form that was created using the out-of-the-box document set form.  However, I cannot create a new one using PowerApps form.  I think it is because it is trying to save the item using the "Document" content type which is part of a document set instead of the custom "Contractor" content type 

@ShriramP  do you have experience with the above use case?

geddb
Helper I
Helper I

Thank you so much @ShriramP for this detailed explanation. Unfortunately, I get an error in the OnStart Property of the App.
- "Navigate is not permitted OnStart. Use the StartScreen property instead."
I cut the Navigate line of code and pasted it in the StartScreen property and got this error message
- "Behaviour function in a non-behaviour property. You can't use this property to change values elsewhere in the app"

geddb_0-1658970594723.png

 


Any assistance will be greatly appreciated.

geddb

geddb
Helper I
Helper I

For anyone experiencing the issue I raised above, @Mostafa supplied an answer that solved my problem. Thank you @Mostafa for the very simple fix 🐵

 

geddb_0-1658971827791.png

 

Thanks @geddb ! And nice to know that you already received help from @Mostafa 🙂

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,436)