Use JSON path when setting up a Trigger condition in Sitecore Content Hub

The problem

Create public links for a specific rendition of all assets except for when a document is created or uploaded.

The brain

All assets have file properties that are part of the system OOTB metadata.

I know a trigger on asset change and action that runs a script is the easiest way to get this done. We could add conditions on a trigger to check the asset type relation and then run a script to create a public link. if all else fails look at a custom solution.

The struggle

Trying to load an asset and its related media and types is a little icky. You can read the entity and try to find the type. If it’s an image, video, or document one can decide to run different tasks. FileType, fileName, and File Property metadata all are accessible but a little convoluted to get and check. So I picked a GUI path and just check the asset file property on the trigger condition. so the trigger won’t even fire let alone check inside the script for a valid scenario.

This was a simple solution, but the only problem was finding an example of how to read JSON values in conditions. Thus I gave birth to this blog post. Just type in property names in the path field and trigger works as expected.

Related links to click if you need to.

https://doc.sitecore.com/ch/en/users/34/content-hub/manage–ootb-schema.html

https://www.sitecored.com/2021/09/sitecore-content-hub-automatically-assign-asset-type.html

~ Do not overdo it. If you can, you will do it. If you can’t, someone else will do it. ~

Download Files from Media Library using Sitecore PowerShell Extension

SPE is a powerful tool. You can do a lot with it. So, whenever I think something needs a lot of manual intervention and can be automated I look into SPE.

So, here I am, trying to download a bunch of files from one Sitecore instance and bring it over for reorganization, renaming and reused.

SPW, has GET-ITEM and SEND-ITEM. So I jump in.

Get-Item -Path "master:" -Query "/sitecore/media library/Images/Habitat/" | Send-File -NoDialog

But, it was only downloading one file. What the cinnamon toast crunch am I missing?

So, I went deeper and dumber and used a script that does Get-Item on the root, Foreach thru all the items, then run Send-File one at a time. No Dice. It only ran once then Sitecore hung.

After a bunch of trials and errors I ditched “-NoDialog” and a heavenly dialog showed up.

Clicked on Download, It downloaded the file. Clicked on Close and another dialog showed up for the next file. And then do this for 346 more time. I think not.

MichaellWest jumped in saying “I believe I have seen that issue before. Can’t seem to find it on github though.”

So, for those in the same boat as me. Please use this instead.

Right click on the Item, Scripts > Download. This works wonder. You will get all your raw files in a zip file.

Still SPE but not scripted.

~ Scratching is as irresistible as Cocain. ~

Sitecore Powershell Extension reports are not exporting to excel or any other format?

You are not alone.

Like lots of other users and organizations do you depend on Powershell Extension to generate reports for you? I am not sure when but the File export of the report output is broken.

The good old PowerShell reports…Screen Shot 2020-03-15 at 2.13.17 PM

The better and older file export.

Screen Shot 2020-03-15 at 2.17.02 PM

I am using the latest and greatest version as well. When you click on Excel or CSV you will be redirected to the login page.

So far I have not found a solution to this problem yet But found a workaround.

using Cognifide.PowerShell.Core.Host;
using (ScriptSession scriptSession = ScriptSessionManager.NewSession("Default", true))
{
    Item speScriptItem = Sitecore.Context.Database.GetItem("/path-or-id/to-spe-item");
    string script = speScriptItem["Script"];
    if (!string.IsNullOrEmpty(script))
    results = scriptSession.ExecuteScriptPart(script, false);
}

I indent to create aspx page or a razor view to generate the report results into a table or a simple request header to generate and server the excel files to the customer.

Please drop me a line if you know of a better way. Much Thanks.

 

 

~ Life is full of ifs and buts, But trail and errors are fill of life. ~