Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Macro Method in Visibility Field in Webpart View modes: 
User avatar
Member
Member
bryson.justus-chickasaw - 2/1/2013 9:23:39 AM
   
Macro Method in Visibility Field in Webpart
I am trying to use CurrentDocument.IsInRelationship() and CurrentDocument.RelatedDocuments["isrealtedto"] in the visibility field of a webpart.

I am having no luck on getting this macros to work.

My goal is to check if the Current Document has any Related Documents and if it does show the webpart and if it doesn't hide the webpart.

Is there a better way to do this than with the macros or what is the proper way to use the .IsInRelationship() and RelatedDocuments macros?

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/4/2013 2:34:31 AM
   
RE:Macro Method in Visibility Field in Webpart
Hello,

You always need to as for a specific relationship and each relation ship has a count property so you can check if this property id greater than 0:
{%CurrentDocument.RelatedDocuments.isrelatedto.Count>0%}

Best regards,
Jan Hermann

User avatar
Member
Member
bryson.justus-chickasaw - 2/7/2013 9:17:49 AM
   
RE:Macro Method in Visibility Field in Webpart
This always returns false. I tried this with the relationship names I created as well as with isrealtedto. I tried it with the CurrentDocument being on left and right of the relationship and still returns false.


Is there any documentation/examples of the CurrentDocument.IsInRelationship() or CurrentDocument.RelatedDocuments["isrealtedto"] methods?

What file does these exist in so that I can atleast reference it to see what they actually do?

User avatar
Kentico Support
Kentico Support
kentico_janh - 2/8/2013 3:25:02 AM
   
RE:Macro Method in Visibility Field in Webpart
Hello,

Are you sure you are using right relationship name? I have tested it and if I set two documents related to my document then I can see them in macro editor as well as the 2 value in the Count property as you can see on the screenshot below:

User image

Please check appropriate path/relationship name in your macro editor.

FYI, these methods are hardcoded into DLL files, so if you don't have a source code, you can't see its source.

Best regards,
Jan Hermann

User avatar
Member
Member
bryson.justus-chickasaw - 2/8/2013 8:36:07 AM
   
RE:Macro Method in Visibility Field in Webpart
I am checking this in the macro editor for the Text field of a Static Text webpart and none of my relationship names show up. The default isrelatedto doesn't even show up.

Is there a way to remedy this? This may be why I haven't had any luck with RelatedDocuments and IsInRelationship methods also.

Thanks for the screenshot that help clear things up for me that something isn't working properly.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 2/10/2013 1:19:17 AM
   
RE:Macro Method in Visibility Field in Webpart
Hi,

The custom relations ship names are not populated - this would require adding them manually - and basically adding every custom thing to the macros would be an overkill.

I used this macro and it worked just fine:
{%CurrentDocument.RelatedDocuments.Any.Count%}


Best regards,
Juraj Ondrus

User avatar
Member
Member
bryson.justus-chickasaw - 2/11/2013 4:39:44 PM
   
RE:Macro Method in Visibility Field in Webpart
I have found where my fault was in the RelatedDocuments method. I had added a field onto my document type named RelatedDocuments. When this field is added to the document type it cause the methods to return Null even if there are Related Documents.

I removed the RelatedDocuments field and created one named RDocs and it is working perfectly now.