cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ShriramP
Frequent Visitor

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
Frequent Visitor

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

View solution in original post

3 REPLIES 3
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

ShriramP
Frequent Visitor

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

View solution in original post

Thanks @v-jefferni !

 

I will surely do so!

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (84,053)