June 2, 200916 yr Hi all, Does anyone know how I can get the name of the file stored in a container, without using a hard-coded field name? This was my idea (below), but it only returns a "?" Evaluate( GetAsText( Left(Get (LayoutTableName); 3) & " • File1" ) ) The table I'm working in is named T2B • Artworks, the container field object name is T2B • File1 Any ideas? I'm trying to have a layout independent script to import/export container field content, which I can use on any layout in any table simply by adjusting the object names of the container fields. Any help much appreciated!!
June 2, 200916 yr Try something like: GetAsText ( GetField ( Get ( LayoutTableName ) & "::" & "FieldName" ) ) or just: GetAsText ( GetField ( "FieldName" ) )
June 4, 200916 yr Author Right... but then it's tied to the field name. Granted, I could name all fields in all tables which store files of any kind the same way - but it would be much more flexible if I could get the information through the object name of the field. That way I could name the field freely according to their purpose. Impossible?
June 4, 200916 yr OK, then how about: GetAsText ( GetField ( GetLayoutObjectAttribute ( "ObjectName" ; "source" ) ) )
June 4, 200916 yr Author I think you just changed the way I program forever... I was totally unaware of the source attribute for the GetLayoutObjectAttribute function. That is super useful! Thank you! I even used $ObjectName for "Object Name" which was previously retrieved as Left(Get (LayoutTableName); 3) & " • File1" - and which makes it entirely portable in my view. All I have to do now on any given layout is give the media field(s) a name based on the convention above, and I can upload, export, email and delete a media file of any kind and format. Time required? A couple of seconds. Fantastic -)
June 4, 200916 yr I don't quite see what role LayoutTableName would play here. You could simply name your object "Container" on every layout, and the formula: GetAsText ( GetField ( GetLayoutObjectAttribute ( "Container" ; "source" ) ) ) will automatically return the filename of the file stored in the current layout's object.
June 4, 200916 yr Author Good point. It can be simplified like you suggest. If I was putting the information in a global variable for some kind of use, I would need something that identifies what layout a certain "container" is located on. But since this is not the case - you're absolutely right.
Create an account or sign in to comment