locked
Assigning null value to a int filed RRS feed

  • Question

  • how can we assign a null value to int filed in an orchestration?

    for ex for string

    we assign like

    message1.tsn=string.empty

    in the same way how to assign it for int filed?

    Wednesday, June 11, 2014 6:17 PM

Answers

  • An Int cannot be assigned nothing. The equivalent to null is 0.

    If you have an Int element that will not be assigned always, you should set the minOccurs to 0 in the Schema.

    Morten la Cour

     
    • Proposed as answer by Girish R. Patil Thursday, June 12, 2014 7:06 AM
    • Marked as answer by Angie Xu Monday, June 16, 2014 1:50 AM
    Wednesday, June 11, 2014 6:33 PM
  • Correct, you can't assign null to value type like that.

    If you need to express null to some target app, you'll have to set xs:nil on the element in a Map.

    Wednesday, June 11, 2014 6:42 PM
    Moderator
  • In your schema you can set the field in question to have a maxOccurs of 0 and thus have no value if the field doesn't exist in your document/message.  You can also add the attribute of nillable="true" to your element and then set it with xsi:nil="true".

    If you're working with variables and not schemas you can use System.Nullable<int> to create an int that can be set to null, although this cannot be utilised directly within your Orchestration as it uses Generics which aren't understood by the Orchestration editor.  In this situation you'd need to have to use a .NET helper class.


    If this is helpful or answers your question - please mark accordingly.
    Because I get points for it which gives my life purpose (also, it helps other people find answers quickly)

    Thursday, June 12, 2014 8:22 AM

All replies

  • An Int cannot be assigned nothing. The equivalent to null is 0.

    If you have an Int element that will not be assigned always, you should set the minOccurs to 0 in the Schema.

    Morten la Cour

     
    • Proposed as answer by Girish R. Patil Thursday, June 12, 2014 7:06 AM
    • Marked as answer by Angie Xu Monday, June 16, 2014 1:50 AM
    Wednesday, June 11, 2014 6:33 PM
  • Correct, you can't assign null to value type like that.

    If you need to express null to some target app, you'll have to set xs:nil on the element in a Map.

    Wednesday, June 11, 2014 6:42 PM
    Moderator
  • In your schema you can set the field in question to have a maxOccurs of 0 and thus have no value if the field doesn't exist in your document/message.  You can also add the attribute of nillable="true" to your element and then set it with xsi:nil="true".

    If you're working with variables and not schemas you can use System.Nullable<int> to create an int that can be set to null, although this cannot be utilised directly within your Orchestration as it uses Generics which aren't understood by the Orchestration editor.  In this situation you'd need to have to use a .NET helper class.


    If this is helpful or answers your question - please mark accordingly.
    Because I get points for it which gives my life purpose (also, it helps other people find answers quickly)

    Thursday, June 12, 2014 8:22 AM