Using CrmDefault Attribute

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

You can use the CrmDefaultAttribute attribute to specify a default value for in input parameter. The following examples show how to set the default for each type.

Example

The following example shows adding the input and output attributes to a CrmNumber property used in a custom workflow activity with the addition of the CrmDefault attribute.

public static DependencyProperty myNumberProperty = DependencyProperty.Register("myNumber", typeof(CrmNumber), typeof(DefaultValueTestActivity));

[CrmInput("My Integer")]
[CrmOutput("My Integer Output")]
[CrmDefault("2322")]
public CrmNumber myNumber
{
    get
    {
        return (CrmNumber)base.GetValue(myNumberProperty);
    }
    set
    {
        base.SetValue(myNumberProperty, value);
    }
}

Example

The following example shows adding the input and output attributes to a String property used in a custom workflow activity with the addition of the CrmDefault attribute.

public static DependencyProperty myStringProperty = DependencyProperty.Register("myString", typeof(System.String), typeof(DefaultValueTestActivity));

[CrmInput("My String")]
[CrmOutput("My String Output")]
[CrmDefault("My Default String")]
public string myString
{
    get
    {
        return (string)base.GetValue(myStringProperty);
    }
    set
    {
        base.SetValue(myStringProperty, value);
    }
}

Example

The following example shows adding the input and output attributes to a CrmBoolean property used in a custom workflow activity with the addition of the CrmDefault attribute.

public static DependencyProperty myBooleanProperty = DependencyProperty.Register("myBoolean", typeof(CrmBoolean), typeof(DefaultValueTestActivity));

[CrmInput("My Boolean")]
[CrmOutput("My Boolean Output")]
[CrmDefault("True")]
public CrmBoolean myBoolean
{
    get
    {
        return (CrmBoolean)base.GetValue(myBooleanProperty);
    }
    set
    {
        base.SetValue(myBooleanProperty, value);
    }
}

Example

The following example shows adding the input and output attributes to a Lookup property used in a custom workflow activity with the addition of the CrmDefault attribute.

public static DependencyProperty myLookupProperty = DependencyProperty.Register("myLookup", typeof(Lookup), typeof(DefaultValueTestActivity));

[CrmInput("My Lookup")]
[CrmReferenceTarget("account")]
[CrmOutput("My Lookup Output")]
public Lookup myLookup
{
    get
    {
        return (Lookup)base.GetValue(myLookupProperty);
    }
    set
    {
        base.SetValue(myLookupProperty, value);
    }
}

Example

The following example shows adding the input and output attributes to a Picklist property used in a custom workflow activity with the addition of the CrmDefault attribute.

public static DependencyProperty myPicklistProperty = DependencyProperty.Register("myPicklist", typeof(Picklist), typeof(DefaultValueTestActivity));

[CrmInput("My Picklist")]
[CrmAttributeTarget("account", "industrycode")]
[CrmOutput("My Picklist Output")]
[CrmDefault("3")]
public Picklist myPicklist
{
    get
    {
        return (Picklist)base.GetValue(myPicklistProperty);
    }
    set
    {
        base.SetValue(myPicklistProperty, value);
    }
}

Example

The following example shows adding the input and output attributes to a CrmDateTime property used in a custom workflow activity with the addition of the CrmDefault attribute.

public static DependencyProperty myDateTimeProperty = DependencyProperty.Register("myDateTime", typeof(CrmDateTime), typeof(DefaultValueTestActivity));

[CrmInput("My DateTime")]
[CrmOutput("My DateTime Output")]
[CrmDefault("2004-07-09T02:54:02Z")]
public CrmDateTime myDateTime
{
    get
    {
        return (CrmDateTime)base.GetValue(myDateTimeProperty);
    }
    set
    {
        base.SetValue(myDateTimeProperty, value);
    }
}

Example

The following example shows adding the input and output attributes to a CrmDecimal property used in a custom workflow activity with the addition of the CrmDefault attribute.

public static DependencyProperty myDecimalProperty = DependencyProperty.Register("myDecimal", typeof(CrmDecimal), typeof(Microsoft.Crm.QA.Workflow.DefaultValueTestActivity));

[CrmInput("My Decimal")]
[CrmOutput("My Decimal Output")]
[CrmDefault("23.45")]
public CrmDecimal myDecimal
{
    get
    {
        return (CrmDecimal)base.GetValue(myDecimalProperty);
    }
    set
    {
        base.SetValue(myDecimalProperty, value);
    }
}

Example

The following example shows adding the input and output attributes to a CrmMoney property used in a custom workflow activity with the addition of the CrmDefault attribute.

public static DependencyProperty myMoneyProperty = DependencyProperty.Register("myMoney", typeof(CrmMoney), typeof(Microsoft.Crm.QA.Workflow.DefaultValueTestActivity));

[CrmInput("My Money")]
[CrmOutput("My Money Output")]
[CrmDefault("232.3")]
public CrmMoney myMoney
{
    get
    {
        return (CrmMoney)base.GetValue(myMoneyProperty);
    }
    set
    {
        base.SetValue(myMoneyProperty, value);
    }
}

Example

The following example shows adding the input and output attributes to a CrmFloat property used in a custom workflow activity with the addition of the CrmDefault attribute.

public static DependencyProperty myFloatProperty = DependencyProperty.Register("myFloat", typeof(CrmFloat), typeof(Microsoft.Crm.QA.Workflow.DefaultValueTestActivity));

[CrmInput("My Float")]
[CrmOutput("My Float Output")]
[CrmDefault("252.2")]
public CrmFloat myFloat
{
    get
    {
        return (CrmFloat)base.GetValue(myFloatProperty);
    }
    set
    {
        base.SetValue(myFloatProperty, value);
    }
}

Example

The following example shows adding the input and output attributes to a Status property used in a custom workflow activity with the addition of the CrmDefault attribute.

public static DependencyProperty myStatusProperty = DependencyProperty.Register("myStatus", typeof(Status), typeof(Microsoft.Crm.QA.Workflow.DefaultValueTestActivity));

[CrmInput("My Status")]
[CrmAttributeTarget("account", "statuscode")]
[CrmOutput("My Status Output")]
[CrmDefault("1")]
public Status myStatus
{
    get
    {
        return (Status)base.GetValue(myStatusProperty);
    }
    set
    {
        base.SetValue(myStatusProperty, value);
    }
}

See Also

Concepts

© 2010 Microsoft Corporation. All rights reserved.