Hello everyone,
I have added some new features to the original attachment page of Dynamics 365, and now I want to add a Check Box in the Document management parameters form so that users can choose whether to enable these new features.
I don’t know how to implement this feature, so I created the “LDCustomizationParameters” table based on the “DocuSharedParameters” table and added it as the data source for the Document management parameters form.
In the LDCustomizationParameter table, I added an enumeration type field called “EnablingContractManagementFeature” to record the choices made by the user. When the value of “EnablingContractManagementFeature” is “No”, the new feature will be in an unavailable state.
But when I tested this feature, I found that clicking Check Box in the form did not correctly change the value of the EnablingContractManagementFeature field.
This causes the value of the “EnablingContractManagementFeature” field to remain “No” and the new feature to remain in an unenabled state.
Perhaps I missed something in my work? Please help me.
Finally, there is the code for the LDCustomizationParameters table, which I copied from the DocuSharedParameters table.
public class LDCustomizationParameters extends common
{
#OCCRetryCount
/// <summary>
/// If no record exists in table, the method adds a default record.
/// </summary>
public LDCustomizationParameters ensureSingleRecordExists()
{
try
{
select firstonly this;
if (!this.RecId)
{
this.EnableContractManagementFeature = NoYes::No;
ttsbegin;
this.insert();
ttscommit;
}
return this;
}
#StandardRetryCatchBlock
}
/// <summary>
/// Checks if the contract management feature is enabled.
/// </summary>
/// <returns>
/// True if the contract management feature is enabled. False if the contract
/// management feature is disabled.
/// </returns>
public boolean isContractManagementFeatureEnabled()
{
return this.EnableContractManagementFeature;
}
/// <summary>
/// Checks if the contract management feature is enabled.
/// </summary>
/// <returns>
/// True if the contract management feature is enabled. False if the contract
/// management feature is disabled.
/// </returns>
public static boolean isContractManagementEnabled()
{
return LDCustomizationParameters::find().isContractManagementFeatureEnabled();
}
/// <summary>
/// Returns a singleton record.
/// </summary>
/// <returns>DocuSharedParameters record</returns>
public static LDCustomizationParameters find(boolean _forUpdate = false)
{
if (!_forupdate && LDCustomizationParametersCacheItem::getLDCustomizationParameters())
{
return LDCustomizationParametersCacheItem::getLDCustomizationParameters();
}
return LDCustomizationParameters::findInternal(_forupdate);
}
/// <summary>
/// Finds the singleton record in the table.
/// </summary>
/// <param name="_forupdate">
/// A boolean value that indicates whether to read the selected record for
/// update; optional.
/// </param>
/// <returns>The singleton record in the table.</returns>
/// <remarks>The method makes sure that a record is returned.</remarks>
internal static LDCustomizationParameters findInternal(boolean _forupdate = false)
{
LDCustomizationParameters ldCustomizationParameters;
ldCustomizationParameters.selectForUpdate(_forupdate);
select firstonly ldCustomizationParameters;
if(!ldCustomizationParameters)
{
return ldCustomizationParameters.ensureSingleRecordExists();
}
LDCustomizationParametersCacheItem::setLDCustomizationParameters(ldCustomizationParameters);
return ldCustomizationParameters;
}
public void insert()
{
super();
LDCustomizationParametersCacheItem::setLDCustomizationParameters(this);
}
public void delete()
{
super();
LDCustomizationParametersCacheItem::setLDCustomizationParameters(null);
}
public void update()
{
super();
// When I modified and saved the value of Check Box, ↓this↓ Info did not appear, so I believe that the update method was not called
Info(strFmt("enable contract management feature is %1", this.EnableContractManagementFeature));
LDCustomizationParametersCacheItem::setLDCustomizationParameters(this);
}
}
LDCustomizationParametersCacheItem Class↓
internal class LDCustomizationParametersCacheItem
{
internal static LDCustomizationParameters cachedLDCustomizationParameters;
public static LDCustomizationParameters getLDCustomizationParameters()
{
return LDCustomizationParametersCacheItem::cachedLDCustomizationParameters;
}
public static void setLDCustomizationParameters(LDCustomizationParameters ldCustomizationParameters)
{
LDCustomizationParametersCacheItem::cachedLDCustomizationParameters = ldCustomizationParameters;
}
}