CRM 2011 Custom Workflow - Get the current fiscal year
-
07-07-2021 - |
Question
I have a custom CRM 2011 workflow which needs to know the current fiscal year. Currently I am just passing in an integer value (2012) for the condition operator, see below:
complianceRecordCondition.AttributeName = "new_complianceStartDate";
complianceRecordCondition.Operator = ConditionOperator.InFiscalPeriod;
complianceRecordCondition.Values.Add(2012);
What I need to do is, instead of adding 2012 in the values, I need to calculate/get the current fiscal year somehow and place that in the values.
Can anyone explain how I go about doing this?
Jack
Solution
I havn't used the fiscal parts myself so I'm a little unfamiliar, but have you seen these other conditional operators?
public enum ConditionOperator
{
...
ThisFiscalYear = 58,
ThisFiscalPeriod = 59,
NextFiscalYear = 60,
NextFiscalPeriod = 61,
LastFiscalYear = 62,
LastFiscalPeriod = 63,
LastXFiscalYears = 64,
LastXFiscalPeriods = 65,
NextXFiscalYears = 66,
NextXFiscalPeriods = 67,
InFiscalYear = 68,
InFiscalPeriod = 69,
InFiscalPeriodAndYear = 70,
InOrBeforeFiscalPeriodAndYear = 71,
InOrAfterFiscalPeriodAndYear = 72,
...
}
They look closer to what you are trying to achieve, in particular ThisFiscalYear
.
I would expect the filter to look a little more like this:
complianceRecordCondition.AttributeName = "intellic_complianceStartDate";
complianceRecordCondition.Operator = ConditionOperator.ThisFiscalYear;
OTHER TIPS
for getting fiscal year in according to crm fiscal year setting you have to fallow these steps.
- Retrieve fiscal year start date from the organization entity.
Then calculate the current fiscal year. You can get code in this link