function [success, diagnostic] = updateWorkflowSetting(workflow, clientData)
    % UPDATEWORKFLOWSETTING update workflow settings
    
    % Copyright 2019-2020 The MathWorks, Inc.

    success = true;
    diagnostic = MException.empty;
    
    workflowSetting = workflow.WorkflowSetting;
    workflowIntent = workflow.WorkflowIntent;
    
    % create a strategy factory instance
    strategyFactory = fxptui.internal.workflowsetting.UpdateSettingStrategyFactory;
    
    fields = fieldnames(clientData);
    for idx = 1:numel(fields)
        % use the field and intent and get the strategy
        field = fields{idx};
        updateSettingStrategy = strategyFactory.getStrategy(workflowIntent, field);
        % get the corresponding value for that field
        value = clientData.(field);
        
        % update the setting
        success = updateSettingStrategy.update(workflowSetting, value);
        
        if ~success
            % return the last diagnostic from the failing strategy
            diagnostic = updateSettingStrategy.Diagnostic;
            break;
        end
    end
    
    
    
end