locked
Declare a variable inside a Expression RRS feed

  • Question

  • Hi,

    I have accessed variables declared in the orchestration and used it in the Expression shape.  But in my case it will be easier if I am able to declare a variable inside the Expression Shape. is it possible to declare a variable inside the Expression Shape ? I tryed

         System.String VariableName

    But it didn't work. I have need so many variables to use it would be easier to declare inside the Expression since i have many expressions in my orchestration.

    Thanks !!
    Wednesday, October 21, 2009 4:16 PM

Answers

  • Hi,

    I do not think it is possible.  When you try to declare variable in expression shape, you get the error 'illegal declarator:declaration may only appear in service or scope".  It looks quite obvious that BizTalk does not allow this.

    Regards,

    Tariq Majeed
    Please mark it as answer if it helps
    Wednesday, October 21, 2009 5:10 PM
  • Hi LilSam21,
    Tariq is 100% correct, you can not declare any variable in expression beacuse it used for writing expression for Orchestration depending on Orchestration variables.
    to declare variable you must go to Orchestration view and right click at variables folder and create new variable,
    after that you can use variable you have declared outside.

    Regards,
    Mohammed Atef 
    http://mohammedatef.wordpress.com/,Please mark reply as answer if it helps
    Wednesday, October 21, 2009 9:28 PM
  • You cannot declare variables inside an expression shape. You can declare variables within the orchestration variables folder which you can see in the orchestration view window in VS. It is better to declare variables within the scope you want to use the variables if the variables are not global. Otherwise you can declare variables in global scope.

    Secondly if you require a lot of variables or array you can use a .NET component and call the component function within the expression shape.


    Abdul Rafay http://abdulrafaysbiztalk.wordpress.com/ Please mark this as answer if it helps
    Thursday, October 22, 2009 6:32 AM

All replies

  • Hi,

    I do not think it is possible.  When you try to declare variable in expression shape, you get the error 'illegal declarator:declaration may only appear in service or scope".  It looks quite obvious that BizTalk does not allow this.

    Regards,

    Tariq Majeed
    Please mark it as answer if it helps
    Wednesday, October 21, 2009 5:10 PM
  • Hi LilSam21,
    Tariq is 100% correct, you can not declare any variable in expression beacuse it used for writing expression for Orchestration depending on Orchestration variables.
    to declare variable you must go to Orchestration view and right click at variables folder and create new variable,
    after that you can use variable you have declared outside.

    Regards,
    Mohammed Atef 
    http://mohammedatef.wordpress.com/,Please mark reply as answer if it helps
    Wednesday, October 21, 2009 9:28 PM
  • You cannot declare variables inside an expression shape. You can declare variables within the orchestration variables folder which you can see in the orchestration view window in VS. It is better to declare variables within the scope you want to use the variables if the variables are not global. Otherwise you can declare variables in global scope.

    Secondly if you require a lot of variables or array you can use a .NET component and call the component function within the expression shape.


    Abdul Rafay http://abdulrafaysbiztalk.wordpress.com/ Please mark this as answer if it helps
    Thursday, October 22, 2009 6:32 AM