Contentful logo

Contentful Community

Is there possibility to have attach Contentful App to content type only in case of specific value in field of that content type?

Hi,
We’are building our first Contentful App and have a requirement that app should display some external content in a specific field of a content type but only in the case if that contentType eg. ‘Animal’ has a proper value in another field named ‘type’. If the value is different than the requested one, app is not needed as content will be populated internally.

So far app is configured for the contentType and displays content for all Animal entries, but I don’t see any possibility there to prevent app installation or uninstall app when an entry has a different value than a targeted one.
I suppose app cannot be installed as requested for some entries, but for all entries of that contentType, so at least confirmation is needed.

Thanks in advance.

@s.ninic You are correct, an app can’t be installed to specific entries with certain field values.

However, you can check within the field which functionality your app should render. You can read the value of the other (‘type’) field using sdk.entry and based on that either render your functionality, disable the field by rendering a fallback, or use our open-source field editors as a fallback (e.g the built-in single line editor).

1 Like

@fabians Thanks again!
This confirmation was needed. I was just about to try this approach as noticed that sdk.entry in field location contains this information I need, so now I can continue with work on that.