Answered by:
pulling variable from incoming file into global variable

Question
-
Is there a way to pull a variable from the transaction header and store it into a global variable and use it in the map?
The schema does not pull in the variable i need from the file in question. If there is a way please give me an example.
ThanksFriday, March 27, 2009 9:00 PM
Answers
-
Hi
Well, if you reference Microsoft.BizTalk.Edi.BaseArtifacts.dll found in the BizTalk installation folder from your project, then inside your orchestration, you can access a whole bunch of automatically promoted properties like this:
IncomingMessage(EDI.CharacterSet) and lots of others. If you start writing "EDI." then intellisense will show you the rest. If you need other values than can be given by these default properties let us know.
-- eliasen, representing himself and not the company he works for.- Marked as answer by fsubob2004 Monday, March 30, 2009 1:21 PM
Monday, March 30, 2009 12:51 PM -
Hi
You can use
Message(BTS.MessageID) to get the internal BizTalk message ID inside an orchestration. If you want this ID copied into your message you have two options:
1. Use a map and us eone of the functoids available at the link Randal supplied.
2. Use a message assignment shape inside a Message construct shape to put the value into a distinguished field like this: Message.MyOwnId = OldMessage(BTS.MessageID)
-- eliasen, representing himself and not the company he works for.- Marked as answer by fsubob2004 Monday, March 30, 2009 1:57 PM
Monday, March 30, 2009 1:27 PM
All replies
-
Here is a quick thought... you could try promoting required variable (if the transaction header you mentioned is some xml message type) and add the property schema as one of the source schemas for the map(using Transform shape)
HTH
Sr ConsultantSaturday, March 28, 2009 2:53 AM -
Hi,
It is not completly clear to me want you want to do. If you want to use a values that is not available in the source schema/message in a map you can:
1) Put that value on the context of the source message and use the context accessor functoids from code plex to get the value in your map. See: http://www.codeplex.com/ContextAccessor
2) Put the value in helper message and use that message together with your source message as sources for the map (Use amap with two source schemas in an orchestration).
HTH,
Randal van Splunteren
http://biztalkmessages.vansplunteren.net
Please mark answered if this answers your question.
HTH, Randal van Splunteren http://biztalkmessages.vansplunteren.net Please mark answered if this answers your question.- Proposed as answer by Naushad.AlamModerator Monday, March 30, 2009 11:48 AM
Saturday, March 28, 2009 9:50 PMModerator -
Here is a quick thought... you could try promoting required variable (if the transaction header you mentioned is some xml message type) and add the property schema as one of the source schemas for the map(using Transform shape)
This will definately not work.
Using a mesage that is the type corresponding to your property schema will not work, becaue even if you declare a message of that ype, you wont get anything into the message, since the context of the original emssage belong to that mesage and will not automtically get copied to a nother message, no maer what type it is.
Randals suggestion is he best way. Promote the values and acces them in a map. The link he provides information about two different functoids - one of them can access context inside a map, when called from an orhestration. The other will let you access context inside a map called from a receive port, but only if you have used a specific pipeline component in the receive pipeline..
-- eliasen, representing himself and not the company he works for.Sunday, March 29, 2009 9:36 PM -
Thank you all for the help. I do not know much about the orchestration parts or promoting but I will go through the links provided. I am a newbie to biztalk. :)Monday, March 30, 2009 12:15 PM
-
Ok, I already have a another question/clarification. The messages we receive are in x12 format and messages have parts that are nested inside of each other. For instance all x12 files have a document header and footer that contain transactional information about the file. There are ids in the header and footer that make that file unique. In Biztalk the schemas only use the inner message which is basically an envelope inside the larger header/footer envelope. I need some of the content from the larger envelope that biztalk strips off. I know it gets passed in and the edi dissassembler breake the message down so biztalk can process it but my question is where does this data go and how can I access it.
The posts above mentioned promoting the fields but how can I promote a field I cannot find is my question. I have read posts here and there about people writing scripts to access things like source filename that biztalk stores somewhere and I need to do the same thing here but with the document header.
Thanks again for all you help!Monday, March 30, 2009 12:35 PM -
Hi
Well, if you reference Microsoft.BizTalk.Edi.BaseArtifacts.dll found in the BizTalk installation folder from your project, then inside your orchestration, you can access a whole bunch of automatically promoted properties like this:
IncomingMessage(EDI.CharacterSet) and lots of others. If you start writing "EDI." then intellisense will show you the rest. If you need other values than can be given by these default properties let us know.
-- eliasen, representing himself and not the company he works for.- Marked as answer by fsubob2004 Monday, March 30, 2009 1:21 PM
Monday, March 30, 2009 12:51 PM -
Thanks thats great. One more thing how would I access the biztalk generated id for the incoming message? Is there a way I can pull that in the orchestration or through c# to assign to a field in my outbound schema as well?
Thanks so much!!!Monday, March 30, 2009 1:24 PM -
Hi
You can use
Message(BTS.MessageID) to get the internal BizTalk message ID inside an orchestration. If you want this ID copied into your message you have two options:
1. Use a map and us eone of the functoids available at the link Randal supplied.
2. Use a message assignment shape inside a Message construct shape to put the value into a distinguished field like this: Message.MyOwnId = OldMessage(BTS.MessageID)
-- eliasen, representing himself and not the company he works for.- Marked as answer by fsubob2004 Monday, March 30, 2009 1:57 PM
Monday, March 30, 2009 1:27 PM -
Very simple I like it! Thanks!Monday, March 30, 2009 1:57 PM
-
OK since you are such a help I got another one that has been bothering me.
I have a c# class I defined and I have been trying to assign a global variable liek BiztalkFunctions.Myglobals.sourcefilename = Message(BTS.MessageID)
For whatever reason it does not assign the value.
I am doing something wrong here?
I call a function in the same class like BiztalkFunctions.IncreaseTransId.Increase(); and it works but my assignment does not.
Thanks
againMonday, March 30, 2009 2:11 PM -
Hi
What error are you geting? The "sourcefilename" needs to be static and public for that to work.
Probably, it would be better to have a method that takes the message ID as a parameter:
BizTalkFunctions.Mymethods.DoSomething(mesage(BTS.MessageID));
-- eliasen, representing himself and not the company he works for.Monday, March 30, 2009 3:56 PM -
I am not receiving an error its just not writing out anything to the destination when called.
"sourcefilename" is static and public
Gotcha I will try the method suggestion and let you know.
Thanks as always... I am learning alot through this!
Have a great day!Monday, March 30, 2009 4:04 PM -
Hey eliasen,
I keep getting specified slot was not valid when trying the functoid from the link.
Here are the inputs I am passing in.
Message_1
MessageID
http://schemas.microsoft.com/BizTalk/2006/file-properties
error
I know its my fault just not sure what I am doing wrong.
ThanksMonday, March 30, 2009 6:14 PM -
Hi
The correct namespace is http://schemas.microsoft.com/BizTalk/2003/system-properties
-- eliasen, representing himself and not the company he works for.Monday, March 30, 2009 6:45 PM -
Huh,
I am still getting Specified slot number was invalid.
any ideas?
ThanksMonday, March 30, 2009 7:04 PM -
Hi
When are you gettig that response? At compile time? As the output of the functoid? You do realize that the functoid only works at runtime, right? You cannot test it from within VS.Net.
-- eliasen, representing himself and not the company he works for.Monday, March 30, 2009 9:17 PM -
Good Morning!
I get that error as the output of the functoid. I am writing it to a db table field.Tuesday, March 31, 2009 11:55 AM -
Well, are you testing at runtime or within VS.NET?
Secondly, are you sure you are using the right functoid? The DLL you download comes with two functoids. One works from within a map called inside an orchestration. The other works in a map in the receive port.
-- eliasen, representing himself and not the company he works for.Tuesday, March 31, 2009 3:06 PM -
I am testing at runtime.
A note I could not get the functoid to work it kept giving me cannot find functoid error even though I registered it in the GAC. So, I took the code out of the functoid and placed it in a class and called it that way.
So this may be my problem but the code was so simple it did not seem like it should have been a problem.Tuesday, March 31, 2009 5:02 PM -
Hi
I haven't seen the code, but I woul definately not extract it to a helper class, but use the functoid as is.
To use it you need to place the DLL in the C:\Program Files\Microsoft BizTalk Server 2006\Developer Tools\Mapper Extensions folder (if C:\Program Files\Microsoft BizTalk Server 2006 is your BizTalk installation folder) and place he DLL in the GAC. That should be it.
Again; Are you sure you are using the correct funtoid and not the one that only works in receive ports?
-- eliasen, representing himself and not the company he works for.Tuesday, March 31, 2009 6:23 PM -
I am using the Orchestration Context Accessor. The functiod is not giving me an error now but it is just returning the fourth parameter I am passing in.
Message_1
BTS.Message_Id
http://schemas.microsoft.com/BizTalk/2003/system-properties
Error
I have tried passing in BTS.Message_Id and Message_Id.
Any other suggestions you may have would be really appreciated. Thank you for not giving up on me. :)Tuesday, March 31, 2009 7:11 PM -
Looking back at you previous post I beleive I am missing a big part.
You said one works from a map called from within an orchestration and one works from within a map called from a receive port.
I believe this is my problem... I am calling the map from a send port in the biztalk administrator. So do I just call the map from the send port instead?Tuesday, March 31, 2009 8:08 PM -
Hi
That will explain it.
As i wrote: One of the functoids only works in a map called inside an orhestration.
The other functoid will only work from within a map called in a receive port.
None of them will work when called from a send port.
If you decide to use the one that only works in a receive port, it REQUIRES that you use the pipeline components that ships with the funtoid in the receive pipeline use before the map.
-- eliasen, representing himself and not the company he works for.Tuesday, March 31, 2009 8:40 PM -
Ok,
I got the functoid to work for the file properties but I still cannot get it to work with the MessageID.
You have been so helpful I really appreciate it. Do I have to include the schema some where?
Here is what I am inputing for file properties and its working
Message_1
ReceivedFileName
http://schemas.microsoft.com/BizTalk/2003/file-properties
This is not working
Message_1
BTS_MessageID
http://schemas.microsoft.com/BizTalk/2003/file-properties
or
Message_1
MessageID
http://schemas.microsoft.com/BizTalk/2003/file-propertiesWednesday, April 1, 2009 1:39 PM -
The name space is wrong. Use this instead:
http://schemas.microsoft.com/BizTalk/2003/system-properties
And use "MessageID" instead of "BTS_MessageID"
--
eliasen, representing himself and not the company he works for.
MVP and three times MCTS in BizTalk.
Blog: http://blog.eliasen.dkWednesday, April 1, 2009 1:57 PM -
I apologize I just did not copy and paste correctly. I am using http://schemas.microsoft.com/BizTalk/2003/system-properties as the name space and MessageID. I went back and tried again and I am getting nothing not even an error.Wednesday, April 1, 2009 2:55 PM
-
Hi
I too appologize. I missed an important point. Please look hre for an explanation: http://blog.eliasen.dk/2009/04/01/TheContextAccessorFunctoidPartI.aspx
--
eliasen, representing himself and not the company he works for.
MVP and three times MCTS in BizTalk.
Blog: http://blog.eliasen.dkWednesday, April 1, 2009 10:56 PM -
Thank you very much this was a very good post. I look forward to your other blog entries.
Being new to Biztalk I still have a list of questions I will be asking in the near future. So I guess I will talk to you soon! :)Thursday, April 2, 2009 2:15 PM -
Being new to Biztalk I still have a list of questions I will be asking in the near future. So I guess I will talk to you soon! :)
Well, it hardly comes as a surprise to you, but that is exactly what the forums are for! So bring 'em on! .-)
--
eliasen, representing himself and not the company he works for.
MVP and three times MCTS in BizTalk.
Blog: http://blog.eliasen.dkThursday, April 2, 2009 7:14 PM -
Hi Eliasen (and fsubob2004),
I have to congratulate you for the setting "the longest thread record" in history of the forums :-)
Great that you kept answering fsubob2004 until it was solved.
Regards,
Randal van Splunteren
http://biztalkmessages.vansplunteren.netFriday, April 3, 2009 7:42 AMModerator -
I have to congratulate you for the setting "the longest thread record" in history of the forums :-)
... and you just HAD to be a part of that record, eh? :-)
--
eliasen, representing himself and not the company he works for.
MVP and three times MCTS in BizTalk.
Blog: http://blog.eliasen.dkFriday, April 3, 2009 8:18 AM -
haha!!!!
I was joking with my colleague the other day that this is the longest thread I have been apart of.
Thanks Again for all your help!Friday, April 3, 2009 4:56 PM