API for Export for/Update from external review #2

Hi,

After the first attempt to export/update external review via API, I have started to use SDL Studio 2014.

It has the proper automated tasks for these, and the export is working properly. However, I can't get to work the update method: it throws the following error:

Unexpected exception when configuring file multiFileConverter for task 'Update from External Review': Expecting element 'ArrayOfExternalReviewMappingItem' from namespace 'http://schemas.datacontract.org/2004/07/Sdl.ProjectApi.Settings'.. Encountered 'Element'  with name 'ArrayOfExternalReviewMappingItem', namespace 'http://schemas.datacontract.org/2004/07/Sdl.ProjectAutomation.Settings'. .

While, I think I properly fill the ExternalReviewMappingItems of the ImportFromReviewTaskSettings settings group before calling the RunAutomaticTask like this way (C#, and UpdateXliffAndreviewedFilepaths is a string Dictionary):


                ISettingsBundle settings = project.GetSettings(trgLanguage);
                
                ImportFromReviewTaskSettings impSettings = settings.GetSettingsGroup<ImportFromReviewTaskSettings>();

                foreach (string xliff in UpdateXliffAndreviewedFilepaths.Keys)
                {
                    impSettings.ExternalReviewMappingItems.Value.Add(new ExternalReviewMappingItem(xliff, project.GetProjectInfo().Id, UpdateXliffAndreviewedFilepaths[xliff]));
                }
                impSettings.Backup.Value = false;
                impSettings.ConfirmationLevel.Value = ConfirmationLevel.Translated;
                project.UpdateSettings(trgLanguage, settings);

                AutomaticTask task = project.RunAutomaticTask(targetFileIDs,
                        AutomaticTaskTemplateIds.UpdateFromExternalReview);
                checkAutomaticTask(task);

The online API documentation of the new external review automatic tasks are very short without any examples. Could you please advice to solve this issue?


Best regards,

 Barnabás

Parents Reply Children
  • I'm struggling with this too. Did you ever get update to work?

    In this example I'm trying to update the first file from the first target langauge (french in this case)

    The code runs without errors, and no taskstatus errors, still the file is not updated in the project.

    Is it necessary to fill in the mappingItem language and Guid? (I tried both with and without)

    EXAMPLE

    Language targetlang=SDLProj.GetProjectInfo().TargetLanguages[0];
    ProjectFile[] targetFiles = SDLProj.GetTargetLanguageFiles(targetlang);
    ISettingsBundle settings = SDLProj.GetSettings(targetlang);
    Sdl.ProjectApi.Settings.ImportFromReviewTaskSettings importTaskSetting = settings.GetSettingsGroup<Sdl.ProjectApi.Settings.ImportFromReviewTaskSettings>();
    Sdl.ProjectApi.Settings.ExternalReviewMappingItem mappingItem = new Sdl.ProjectApi.Settings.ExternalReviewMappingItem(targetFiles[0].LocalFilePath, SDLProj.GetProjectInfo().Id, @"U:\fr-FR\TestFile1.mif.review.docx");


    mappingItem.Language = targetlang;
    mappingItem.Guid=targetFiles[0].Id;
     
      
    importTaskSetting.ExternalReviewMappingItems.Value.Add(mappingItem);
    importTaskSetting.Backup.Value = false;
    importTaskSetting.ConfirmationLevel.Value = ConfirmationLevel.ApprovedTranslation;

    SDLProj.UpdateSettings(targetlang, settings);
    List<ProjectFile> targetFilesList = new List<ProjectFile>();
    targetFilesList.Add(targetFiles[0]);
    targetFiles = TargetFilesList.ToArray();

    AutomaticTask update = SDLProj.RunAutomaticTask(targetFiles.GetIds(), AutomaticTaskTemplateIds.UpdateFromExternalReview);

  • There are 2 things that you need to change for this to work:

    1. Change the line importTaskSetting.ExternalReviewMappingItems.Value.Add(mappingItem); into something like this:

    var mappings = new List<ExternalReviewMappingItem>();
    mappings.Add(mappingItem);

    importTaskSetting.ExternalReviewMappingItems.Value = mappings;

    2. Save the project before run the automatic task

    Tip: To see the possible error messages from the automatic task the returned object, in you case update, has a Messages property where you can see if there where any errors

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/