Setting TM Segment userdefined fields

Hello,

some of our clients have created TM's with userdefined Fields and values. They want us to fill in the values, when they Update their master TMs with new segments. I did not find something in the API doc to fill the values for each segment. I only found functionallity to create userdefinied fields and values in a TM.

Is this possible somehow? Perhaps I missed something?

Best regards,

-Stephan Tandel-

Parents Reply
  • Hey Sébastien, hey Patrik,

    thank you for the replys. We got bit further, but my colleague is now somehow stuck with the SDL API Doc and no API errors being sent back...

    He tried several variants of this:

    ISettingsBundle settings = project.GetSettings();

    Sdl.ProjectAutomation.Settings.TranslationMemorySettings tmSettings = settings.GetSettingsGroup<Sdl.ProjectAutomation.Settings.TranslationMemorySettings>();

                   FieldValues fieldValuesCollection = new FieldValues();

                   FieldDefinition field = tm.FieldDefinitions["Customer"];

                   FieldValue fv = field.CreateValue();

                   fv.Parse("test customer");

                   fieldValuesCollection.Add(fv);

                   tmSettings.ProjectSettings.Value = fieldValuesCollection;

                   project.UpdateSettings(settings);

    This looks ok to me, and does not bring back any errors, but doesn't do anything. Sébastians idea is not usable for me. I do not manipulate the pure xml if there is an API. The API is then useless. Also I don't know if SDL has anything in memory or not. Last but not least, there is no definition for the SDL file formats. So they can change anything anytime and you can never validate your changes.

Children
  • Can you check this sample:

    /// <summary>

           /// Change default import settigns

           /// </summary>

           /// <param name="importSettings"></param>

           private void AdaptImportSettigns(ImportSettings importSettings)

           {

               importSettings.CheckMatchingSublanguages = true;

               importSettings.OverwriteExistingTUs = true;

               //set behavior of existing field values during import

               importSettings.ExistingFieldsUpdateMode = ImportSettings.FieldUpdateMode.Merge;

               //set behavior of new fields during import

               importSettings.NewFields = ImportSettings.NewFieldsOption.AddToSetup;

               //create a field (now using field already existing in the TM setup)

               Field cru = new Field("Sample text field", FieldValueType.MultipleString);

               //set the field value object

               MultipleStringFieldValue cruVal = new MultipleStringFieldValue("Sample text field");

               //add new value (this time we use multiple string field value

               cruVal.Add("Added during import");

               //create field values object

               FieldValues fields = new FieldValues();

               //add the field value

               fields.Add(cruVal);

               //set the field values to the import settigns

               importSettings.ProjectSettings = fields;

           }