TM fields update: what's wrong?!

Hi everyone,

I have been pulling my hairs for two days on my part of the script which should set the TM fields update. My code is similar to the one of the SDK documentation but it seems that the field values are not stored in the projectsettings of my project.

Here is my code:

ISettingsBundle projSettings = newSDLProject.GetSettings();

TranslationMemorySettings projTMSettings = projSettings.GetSettingsGroup<TranslationMemorySettings>();

FileBasedTranslationMemory refTM = new FileBasedTranslationMemory(@"C:\Temp\RefTM.sdltm");

FieldValues tmFields = new FieldValues();

FieldDefinition fieldJobNo = refTM.FieldDefinitions["Doc. Code"];

FieldValue fvJob = fieldJobNo.CreateValue();

fvJob.Name = "139998";

            tmFields.Add(fvJob);

            projTMSettings.ProjectSettings.Value = tmFields;

            newSDLProject.UpdateSettings(projSettings);

This block of code is one part of a method where I create a project. I ran before or after having the project but it does not change anything. I am a bit lost and would be happy for some support.

Thanks in advance.

Regards,

Laurent

Parents
  • Well, after some searches, I have not solved my problem yet but I think I have a better idea of where the problem is coming.

    First, to set a value to a fieldvalue, it is not the "Name" property which should be used! Maybe the SDK documentation could be corrected...

    Second, when I want to use the method fieldValue.Add(String), I receive the following error message:

    Invalid method call on this type

    I know that the script to add the field value to the collection of fieldvalues is correct since I can see it in the XML of the .sdlproj file. However, I cannot set its value.

    When I just add the field based on the field definition of the TM (which I now retrieve from a server TM and not a local TM as described in the code above), the value tag in the xml file is added with the following parameter i:nil="true":

    <FieldValue i:type=":SingleStringFieldValue">

    <Name>Doc. Code</Name>

    <Value i:nil="true">

    </Value>

    </FieldValue>

    Maybe that is the reason why I cannot set a value to the field? However, I do not know what this i:nil refers to...

    Thanks in advance to anyone who can help me on this one.

    Have a nice evening.

    Laurent

Reply
  • Well, after some searches, I have not solved my problem yet but I think I have a better idea of where the problem is coming.

    First, to set a value to a fieldvalue, it is not the "Name" property which should be used! Maybe the SDK documentation could be corrected...

    Second, when I want to use the method fieldValue.Add(String), I receive the following error message:

    Invalid method call on this type

    I know that the script to add the field value to the collection of fieldvalues is correct since I can see it in the XML of the .sdlproj file. However, I cannot set its value.

    When I just add the field based on the field definition of the TM (which I now retrieve from a server TM and not a local TM as described in the code above), the value tag in the xml file is added with the following parameter i:nil="true":

    <FieldValue i:type=":SingleStringFieldValue">

    <Name>Doc. Code</Name>

    <Value i:nil="true">

    </Value>

    </FieldValue>

    Maybe that is the reason why I cannot set a value to the field? However, I do not know what this i:nil refers to...

    Thanks in advance to anyone who can help me on this one.

    Have a nice evening.

    Laurent

Children
No Data