Crow Canyon Software Forum

Forum Navigation
Please or Register to create posts and topics.

Is it possible to hide a tile on a page if a list has entries?

Hello,

We have a tile on one of our pages we would like to hide if there are forms in a list - is this possible?

Thank you in advance,

Brian.

Hi @briankoch,

I believe you are using "Crow Canyon Titles and Dials", "Manage Link Tiles" on your home page for showing the number of items using "Count" option in "Display Type" setting of the link tile. Please confirm.

If yes, do you want to hide the tile if there are "items" in the source list view or hide the tile if there are "no items" in the source list view?

Please note that we have a direct option to show/hide a tile in Link Tiles group based on logged in user's SharePoint group membership. But for acheiving other custom behaviors, we have "Custom JavaScript" option. For checking the possibilities, I would like to make sure that I understand the requirement.

Hi Pavan!

Yes - using Crow Canyon Tiles and Dials, it's a link tile - we're not showing the number of items on this tile - just text.  We would like to hide the tile if there are items in the source list.

Thank you so much!

Hi Brian,

This is possible using the Custom JavaScript option.

Please refer http://crowcanyonapps.azurewebsites.net/apppages/Portal/scriptCode.aspx for sample use case.

In this example, we are overriding the tile text and URL based on logged in user and the status of list item.

For hiding the tile, we need to use below line of code. Full script for your use case is attached (HideTile_BasedOnItemCount.pdf). Please replace siteURL and listName variable values with your site URL and list name.

$("#" + paramTileInfo.Guid).remove();

Uploaded files:

Thank you Pavan!

I was able to come up with a better solution than what I was originally going for.  I am able to have a single tile now to either Edit the existing form or Add a New form if one doesn't exist.  I've included my mashed up Javascript in case anyone else is looking to do something similar.

Thank you again!

Brian.

This is the Javascript I used:

//the default tile text indicates to click the tile to add a new form the default URL is the new form url (this is the default)

var siteURL = "https://tenancy.sharepoint.com/sites/sitecollection/site";
var listName = "list name"
var ClientDataListUserColumnName = "personobjectcolumnname"; // The column containing the Person object to check items for
var restAPIQuery = siteURL + "/_api/web/Lists/getByTitle('" + listName + "')/Items?$select=ID,Title/Id&$Filter=" + ClientDataListUserColumnName + "/Id%20eq%20" + paramUserID + "&$orderby=Created%20desc&$top=1";
$.ajax
({
url : restAPIQuery,
method : "GET",
headers : {
"Accept" : "application/json; odata=verbose"
},
success : function (data) {
if (data.d.hasOwnProperty("results") && data.d.results.length > 0) {
//if there are any forms found, only allow the user to edit the existing form
var listItem = data.d.results[0]
var clientDataEditPageURL = siteURL + "/SitePages/CCSDisplayForm.aspx?ListID='hard coded list id here'&ItemID=" + listItem.ID + "&ContentTypeId=0x0100EA641375BB2E48499E1AFC4007AF3CEC";
paramTileInfo.Text = "Click here to edit your FORM NAME HERE Form"; // Set tile Text for Edit
paramTileInfo.URL = clientDataEditPageURL; // Set tile URL as per the status
}
functionCallback(paramTileInfo);
},
error : function () {
functionCallback(paramTileInfo);
},
async : true
});

James Restivo has reacted to this post.
James Restivo