How to validate that a picture field has value or not in a script rule?

Question

I want to write a script rule in C# to validate if the picture field has any value or not.

Answer

It is possible to validate if a picture field has an image or not by counting regions. If it is empty then the regions count will be 0:

if (Context.Field("pictureField").Regions.Count > 0)
{
    //do something
}
else
{
   //do something
}

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.