Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the CollectiveAccess support forum! Here the developers and community answer questions related to use of the software. Please include the following information in every new issue posted here:

  1. Version of the software that is used, along with browser and version

  2. If the issue pertains to Providence, Pawtucket or both

  3. What steps you’ve taken to try to resolve the issue

  4. Screenshots demonstrating the issue

  5. The relevant sections of your installation profile or configuration including the codes and settings defined for your local elements.


If your question pertains to data import or export, please also include:

  1. Data sample

  2. Your mapping


Answers may be delayed for posts that do not include sufficient information.

Prepopulate on media representation preferred labels

edited March 17 in Troubleshooting
Hello !

I'm trying to prepopulate the title (preferred label) on media representation based on the related record so the representation has the same name than the object (because they are scans of the record).
I set this entry in the prepopulate config file :

    Nom_RepresentationMedia= {
        # what types of records does this rule apply to?
        table = ca_object_representations,
        restrictToTypes = [],

        # mode determines handling of existing values in target element
        # can be overwrite, or addIfEmpty
        # See the 'target' setting below and http://docs.collectiveaccess.org/wiki/Prepopulate
        mode = addIfEmpty,

        # What's the prepopulate target?
        # This can be an intrinsic field, labels or an attribute.
        #
        # Note that if you want to target a List attribute, you have to
        # provide a valid list item idno or id for that list as value!
        #
        # See http://docs.collectiveaccess.org/wiki/Prepopulate
        target = ca_object_representations.preferred_labels,

        # skip this rule if expression returns true
        # available variable names are bundle names
        #skipIfExpression =  ,

        # content to prepopulate
        # (this is a display template evaluated against the current record)
        template = ^ca_objects.preferred_labels
    },

But it does'nt work... I'm still having the [BLANK] value. What am i doing wrong ?

Thanks !

John

Comments

  • Hi John,

    I had similar issue, I wanted to set the title of my images to the name of the uploaded file. It took some time, but I was able to solve it.
    At first, preferred_labels are particular fields in CA database, not simple attributes.

    If you have 
    require_preferred_label_for_ca_object_representations = 0
    setting in your app.conf, and you don't fill the field, it gets the value "[BLANK]". After that, prepolulation plugin finds that the field is not empty, and it does nothing.
    My rule in prepopulate.conf looks like this:
    object_representations_title_rule = {
    table = ca_object_representations,
    #restrictToTypes = [],
    mode = overwrite,
    target = ca_object_representations.preferred_labels.name,
    skipIfExpression = ^ca_object_representations.preferred_labels.name !~ /\[BLANK\]/,
    template = ^ca_object_representations.original_filename,
    }

    I think you will have to change the value of your template setting, too.
    I am not sure, but something like this would work: template = <unit relativeTo="ca_object_representations"><unit relativeTo="ca_objects"><ifdef code="ca_objects.preferred_labels.name">^ca_objects.preferred_labels.name </ifdef></unit></unit>

    One more remark:
    It won't work, if you have 
    require_preferred_label_for_ca_object_representations = 1
    setting in your app.conf
    You got the error message about empty label before prePopulate plugin could do its work.

    Regards,
    Laszlo
  • Hi Laszlo !

    Thanks for your rule ! It works fine !
    You're awesome !

    Regards,
    John

  • Hello again !

    We are also using the media representation bundle in the object basic info screen to add pdf files directly (It's easier for the users).
    So i tried to adapt the rules to automatically add a title and an id to the representation but couldn't get it to work using this :

        Id_RepresentationMedia_FIche= {
            # what types of records does this rule apply to?
            table = ca_objects,
            #restrictToTypes = [],
            mode = addIfEmpty,
            target = ca_objects.ca_object_representations.idno,
            #skipIfExpression = ^ca_object_representations.preferred_labels.name !~ /\[VIDE\]|\[BLANK\]|\[LEEG\]|\[LEER\]/,
            template = ^ca_objects.ca_object_representations.original_filename,
        },
        # -------------------
        Nom_RepresentationMedia_Fiche= {
            # what types of records does this rule apply to?
            table = ca_objects,
            #restrictToTypes = [],
            mode = overwrite,
            target = ca_objects.ca_object_representations.preferred_labels.name,
            skipIfExpression = ^ca_objects.ca_object_representations.preferred_labels.name !~ /\[VIDE\]|\[BLANK\]|\[LEEG\]|\[LEER\]/,
            #template = ^ca_object_representations.original_filename,
            template =^ca_objects.ca_object_representations.original_filename
        },

    or, because i thought to the flattened container rule, using this :

        Id_RepresentationMedia_FIche= {
            # what types of records does this rule apply to?
            table = ca_objects,
            #restrictToTypes = [],
            mode = addIfEmpty,
            target = ca_objects.ca_object_representations.idno,
            #skipIfExpression = ^ca_object_representations.preferred_labels.name !~ /\[VIDE\]|\[BLANK\]|\[LEEG\]|\[LEER\]/,
            template = ^ca_objects.ca_object_representations.original_filename,
        },
        # -------------------
        Nom_RepresentationMedia_Fiche= {
            # what types of records does this rule apply to?
            table = ca_objects,
            #restrictToTypes = [],
            mode = overwrite,
            target = ca_objects.ca_object_representations.name,
            skipIfExpression = ^ca_objects.ca_object_representations.name !~ /\[VIDE\]|\[BLANK\]|\[LEEG\]|\[LEER\]/,
            #template = ^ca_object_representations.original_filename,
            template =^ca_objects.ca_object_representations.original_filename
        },

    Does anyone have an idea ?

    Thanks again !

    John
Sign In or Register to comment.