web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Personalization using x++

(0) ShareShare
ReportReport
Posted on by 390

Hey Team,

I have written  a code to add some personalization files to my associates created but what I can see is that the files are getting added to the associate but the personalization does not seem to get applied to the respective associate. Please help me inspect my code if there is something I'm missing in my code, some table or method which needs to used. 

My code:( I have used hard coded values only for testing till I get the desired output)

       DocuRef docuref;
        DocuValue   docuvalue;      
        XmlElement          OwnerValue;
        FormRunConfigurationOwner _owner;
        XmlNode xmlNode;        
        FormRunConfigurationOptions formRunConfigurationOptions;
        FormRunConfiguration formRunConfiguration;           
        Set processedDocuName = new Set(Types::String);

        try
        {
       while select docuRef              
    order by ModifiedDateTime desc
    where docuref.RefTableId == 17136
           join docuvalue
    where docuvalue.RecId == docuref.ValueRecId
       {
           if (processedDocuName.in(docuRef.Name))
           {
               continue;
           }
    
           processedDocuName.add(docuRef.Name);
              
            XmlDocument xmlDoc = XmlDocument::newFromStream(DocumentManagement::getAttachmentStream(docuRef));
            xmlNode = xmlDoc.getNamedElement('FormRunConfigurationSerializer').getNamedElement('OwnerValue');           
            _owner = xmlNode.text();
            info(strFmt("Owner Name: %1", _owner));
            
            ttsbegin;
            formRunConfiguration.Owner = _owner;
            formRunConfiguration.Scope = FormRunConfigurationScope::User;
            formRunConfiguration.User = "xyz.abc";
            formRunConfiguration.IsDefault = NoYes::Yes ;
            formRunConfiguration.Company = curExt();
            formRunConfiguration.Name = "Default";
            formRunConfiguration.Version = 1;
            formRunConfiguration.FormViewOptionType = FormRunConfigurationFormViewOptionType::Default;
            formRunConfiguration.insert();
           
            formRunConfigurationOptions.clear();
            formRunConfigurationOptions.User        = "abc.xyz";
            formRunConfigurationOptions.Owner       = _owner;
            formRunConfigurationOptions.Enabled     = NoYes::Yes;
            formRunConfigurationOptions.EnabledExplicitPersonalization = UnknownNoYes::Yes;
            formRunConfigurationOptions.insert();
            FormRunConfigurationHelper::resetUserEnabledCaches();


            ttscommit;
                         
       }
       Info(strFmt("Files have been added succesfully for: %1",formRunConfiguration.User));
      }
      catch(Exception::Error)
      {
          Info(strFmt("Cannot add files"));
      }

I have the same question (0)
  • Sergei Minozhenko Profile Picture
    23,093 on at

    Hi skd,

    Could you, please, provide more details about your requirement? Are you trying to update form configuration from file?

  • skd Profile Picture
    390 on at

    Hey Sergei Minozhenko,

    I have some personalization files in my DocuRef table so I'm selecting them and inserting data into FormRunConfiguration table and FormRunConfigurationOptions Table so that the respective personalization gets added to that associate.(There is no prior personalization to that associate).

  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi skd,

    Why do you need to code something for personalizing things in D365FO?

    Can you elaborate on that?

    Many thanks,

    Ludwig

  • skd Profile Picture
    390 on at

    Hey Ludwig Reinhard,

    Basically, associates get added through a batch job and there are some personalization which we want to add to those associates once the associates are created, we want this done automatically so that no one has to explicitly work on it (Company Requirement)

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi skd,

    When you say associates get added through a batch job, do you mean that you are adding users using a batch job?

  • skd Profile Picture
    390 on at

    Hey Gunjan Bhattacharyya,

    Yes.

  • Suggested answer
    Ludwig Reinhard Profile Picture
    Microsoft Employee on at

    Hi skd,

    Does this also cover automatic role assignments?

    Andre created a great blog post about this here: dynamicspedia.com/.../

    If you automatically assign roles to users then you can share also the personalized views that are assigned to this role and you don't need a system modification for that. This simply works by saving views and publishing them for the different roles that you have. For details, have a look at this MS docs site: docs.microsoft.com/.../saved-views

    Would that be an alternative option for you?

    Best regards,

    Ludwig

  • Jason Green Profile Picture
    on at

    Agree that Saved views is the recommended way to roll out personalizations to employees.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 611 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 529 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 285 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans