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"));
}