Can I query a Translation Job using a "like" or "contains" when searching for a field

I have a query where I am trying to get the value from a specific field in a translation job.   In the query, I specify the file name and the job status  as follows:

string xmlRequestedMetadata1 = "<ishfields><ishfield name='FISHTRANSJOBREQUIREDDATE' level='none'/></ishfields>";
string xmlMetadataFilter1 = <ishfields><ishfield name='FNAME' level='none'>fileName</ishfield><ishfield name='FISHTRANSJOBSTATUS' level='none'>Export completed</ishfield> </ishfields>
xmlObjectList = tJobClient.Find(xmlMetadataFilter1, xmlRequestedMetadata1);

 When there is nothing unusual about the file name, I get back the data expected.

However, if the file name contains non alphanumeric characters like a comma in it, I get back nothing.  I am not sure if the unexpected character is causing the query to break or if Tridion stores the file name as something different due to the unexpected character.

Is there a way that I can modify the query so that insatead of having something like where filename = "XXX", I can have where filename like  "X" or contains "X"?

Saul

emoji
  • Hi Saul,

    Sure you can, the field FNAME is a STRING field. Metadata filter is described on https://docs.rws.com/992527/70920/tridion-docs-15/metadatafilter, in turn the operators allowed are described on https://docs.rws.com/992527/68174/tridion-docs-15/understanding-metadata-filter-operators Note that "cilike" (case insensitive like) is only available starting Tridion Docs 15/15.0.0.

    So you could write the below (I think the wildcard is a star, perhaps a percentage, but I think the star :))

    string xmlMetadataFilter1 = <ishfields><ishfield name='FNAME' level='none' ishoperator='like'>fileNa*</ishfield><ishfield name='FISHTRANSJOBSTATUS' level='none'>Export completed</ishfield> </ishfields>
    

    The comma, or more accurately comma-space combination is a convention on the SOAP API regarding multi-value fields. So specifying "Low, High" for resolution. This convention is however only triggered for fields which are marked as multi-value string fields. Your FNAME field is however a single-value string field as you could see using Get-IshTypeFieldDefinition under column MM. Where first (M)andatory is either - or M(andatory), and second (M)ulti-value is either 1 (single) or n (many/multi).

    Hope this helps,
    Dave


    emoji
  • Dave:

    I have updated my query as per your instructions, but I still don't get any results.  This is my test code:

    TranslationJob25ServiceReference.TranslationJobClient tJobClient = new TranslationJob25ServiceReference.TranslationJobClient();
    tJobClient.ClientCredentials.UserName.UserName = config.TdUser;
    tJobClient.ClientCredentials.UserName.Password = config.TdPassword;

    Log.Information("Trying new query to get the file names given contains with %");
    try
    {
    string xmlRequestedMetadata2 = "<ishfields><ishfield name='FNAME' level='none'/></ishfields>";
    string xmlMetadataFilter2 = "<ishfields>" +
    "<ishfield name='FNAME' level='none' ishoperator='like'>IK%</ishfield>" +
    "<ishfield name='FISHTRANSJOBSTATUS' level='none'>Export completed</ishfield> " +
    "</ishfields>";
    string xmlObjectList = tJobClient.Find(xmlMetadataFilter2, xmlRequestedMetadata2);
    Log.Information("Response from 'Find method is " + xmlObjectList);
    }
    catch (Exception e1)
    {
    Log.Error(e1.Message);
    }

    Log.Information("Trying new query to get the file names given contains with *");
    try
    {
    string xmlRequestedMetadata2 = "<ishfields><ishfield name='FNAME' level='none'/></ishfields>";
    string xmlMetadataFilter2 = "<ishfields>" +
    "<ishfield name='FNAME' level='none' ishoperator='like'>IK*</ishfield>" +
    "<ishfield name='FISHTRANSJOBSTATUS' level='none'>Export completed</ishfield> " +
    "</ishfields>";
    string xmlObjectList = tJobClient.Find(xmlMetadataFilter2, xmlRequestedMetadata2);
    Log.Information("Response from 'Find method is " + xmlObjectList);
    }
    catch (Exception e1)
    {
    Log.Error(e1.Message);
    }

    And this is the response that I get:

    2024-05-22 18:44:38.288 -05:00 [INF] Trying new query to get the file names given contains with %
    2024-05-22 18:44:40.788 -05:00 [INF] Response from 'Find method is <?xml version="1.0" encoding="utf-16"?><ishobjects />
    2024-05-22 18:44:40.788 -05:00 [INF] Trying new query to get the file names given contains with *
    2024-05-22 18:44:41.288 -05:00 [INF] Response from 'Find method is <?xml version="1.0" encoding="utf-16"?><ishobjects />

    There should be 8 translation jobs.

    If I try the following:

    Log.Information("Trying new query to get the file names given the status");
    try
    {
    string xmlRequestedMetadata2 = "<ishfields><ishfield name='FNAME' level='none'/></ishfields>";
    string xmlMetadataFilter2 = "<ishfields>" +
    "<ishfield name='FISHTRANSJOBSTATUS' level='none'>Export completed</ishfield> " +
    "</ishfields>";
    string xmlObjectList = tJobClient.Find(xmlMetadataFilter2, xmlRequestedMetadata2);
    Log.Information("Response from 'Find method is " + xmlObjectList);
    }
    catch (Exception e1)
    {
    Log.Error(e1.Message);
    }

    So that I want all file names where the status is Export completed, I get the following response:

    2024-05-22 18:54:21.448 -05:00 [ERR] The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

    Do you see if I am doing something incorrect or have overlooked something?

    Thanks,


    Saul

    emoji
  • Hi Saul... took a while as we were landing a Tridion Docs 15.1 release...

    Anyway, I actually wrote some 'working' code using the ISHRemote proxies. You probably recognize what needs to map to your C# code (tjJobClient)

    # Get-IshLovValue -LovId DTRANSJOBSTATUS
    $xmlMetadataFilter2 = "<ishfields> <ishfield name='FNAME' level='none' ishoperator='like'>Test%</ishfield> <ishfield name='FISHTRANSJOBSTATUS' level='none' ishvaluetype='element' ishoperator='equal'>VTRANSJOBSTATUSRESOLVED</ishfield> </ishfields>" # or VTRANSJOBSTATUSEXPORTCOMPLETED
    $xmlRequestedMetadata2 = "<ishfields><ishfield name='FNAME' level='none' ishvaluetype='value'/><ishfield name='FISHTRANSJOBSTATUS' level='none' ishvaluetype='value'/><ishfield name='FISHTRANSJOBSTATUS' level='none' ishvaluetype='element'/></ishfields>"
    [xml]$xml = $ISHRemoteSessionStateIshSession.TranslationJob25.Find($xmlMetadataFilter2, $xmlRequestedMetadata2)
    $xml.ishobjects.ishobject.ishfields.ishfield

    Some quick remarks...

    • Line 1, as TranslationJob Status is a database enum, you are better off to use the never-changing "element" name. Theoretically your label "Export Completed" could change, while element name "VTRANSJOBSTATUSEXPORTCOMPLETED" is your readible identifier (forever)
    • Line 2, the wildcard operator is percentage (%) and the 'like' operator is case-sensitive!
    • Also Line 2, I used element name "VTRANSJOBSTATUSRESOLVED" because my test environment did not have Translation Jobs parked in status "VTRANSJOBSTATUSEXPORTCOMPLETED" - make sure to change that. Also note that I explicitedly added the @ishoperator although I did not test if that should have mattered, it is a good practice though.
    • Line 3, extended requested metadata with both label and element of FISHTRANSJOBSTATUS to allow me to validate.
    • Line 4, is the PowerShell way to force the returning "string" to be read as an xml object
    • Line 5, is the dirty :-)  PowerShell way to quickly print ishfield values from the returned objects

    I hope I unblocked you, or somebody else.

    Best wishes,
    Dave 

    emoji
  • Dave:

    It now works. Thanks for the response.  Super helpful.

    Saul

    emoji