<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Context Variable value not working in Talend Studio</title>
    <link>https://community.qlik.com/t5/Talend-Studio/Context-Variable-value-not-working/m-p/2250675#M34859</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thanks for your response. Can you explain the solution a little bit more.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;In the actual job I am using a parameter text file to load the context values. In my job I am not hard coding any context value. I am only defining the context name and call it from a text file.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;So how I can define the numeric (-2) value in a context variable?&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;TalendDate.formatDate("MMyy",(TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),&lt;U&gt;&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;-2&lt;/FONT&gt;&lt;/U&gt;,"MM")))).toString()&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Because I don't want to touch the job in future, rather I will change the context variable value in&amp;nbsp; the text file.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I will appreciate if you can give me an example.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Feb 2019 14:46:05 GMT</pubDate>
    <dc:creator>Tasfiahm</dc:creator>
    <dc:date>2019-02-08T14:46:05Z</dc:date>
    <item>
      <title>Context Variable value not working</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Context-Variable-value-not-working/m-p/2250672#M34856</link>
      <description>&lt;P&gt;Hi Expert,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I am using a t_OutputExcel component to write data in a folder. In the file output file name, I am using multiple context variable to define the directory as well as file name.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I am using a talend&amp;nbsp;getdate&amp;nbsp;function to get the month :&lt;/P&gt; 
&lt;P&gt;TalendDate.formatDate("MMyy",(TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM")))).toString()&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;The Hardcoded function works correctly but when I assign the same value in the context variable It is giving me an error:&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;[statistics] connected&lt;BR /&gt;[FATAL]: talend_default.tFileOutputExcel_1 \\me\d\2\E\D\l_1218-TalendDate.formatDate("MMyy",(TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM")))).toString().xlsx (The filename, directory name, or volume label syntax is incorrect)&lt;BR /&gt;Exception in component tFileOutputExcel_1&lt;BR /&gt;java.io.FileNotFoundException: \\me\d\2\E\D\l_1218-TalendDate.formatDate("MMyy",(TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM")))).toString().xlsx (The filename, directory name, or volume label syntax is incorrect)&lt;BR /&gt;at java.io.FileOutputStream.open0(Native Method)&lt;BR /&gt;at java.io.FileOutputStream.open(Unknown Source)&lt;BR /&gt;at java.io.FileOutputStream.&amp;lt;init&amp;gt;(Unknown Source)&lt;BR /&gt;at java.io.FileOutputStream.&amp;lt;init&amp;gt;(Unknown Source)&lt;BR /&gt;at org.talend.ExcelTool.writeExcel(ExcelTool.java:294)&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I have two options: ( I preffer option 2 just defining the Integer value -1)&lt;/P&gt; 
&lt;P&gt;1. Is using the&amp;nbsp; full function inside the context:&amp;nbsp;(TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM")))).toString()&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;2. Using only the -1 to define the month and then call it :&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;context.NM_END_MMYY&amp;nbsp; &amp;gt;type int&amp;nbsp;&amp;gt; value -1&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;(TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(), + context.NM_END_MMYY +,"MM")))).toString()&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Currently, I am coding it like this:&lt;/P&gt; 
&lt;P&gt;File Name::&lt;/P&gt; 
&lt;P&gt;context.NM_MSK + TalendDate.formatDate("MMyy",(TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(), -2,"MM")))).toString() + "-" + context.END_MMYY + ".xlsx"&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 15:34:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Context-Variable-value-not-working/m-p/2250672#M34856</guid>
      <dc:creator>Tasfiahm</dc:creator>
      <dc:date>2019-02-07T15:34:25Z</dc:date>
    </item>
    <item>
      <title>Re: Context Variable value not working</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Context-Variable-value-not-working/m-p/2250673#M34857</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can not use functions as a context value - this is no doubt&lt;/P&gt;&lt;P&gt;you must use context for store fixed part of name + function for define variable part of the name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 21:19:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Context-Variable-value-not-working/m-p/2250673#M34857</guid>
      <dc:creator>vapukov</dc:creator>
      <dc:date>2019-02-07T21:19:47Z</dc:date>
    </item>
    <item>
      <title>Re: Context Variable value not working</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Context-Variable-value-not-working/m-p/2250674#M34858</link>
      <description>&lt;P&gt;Well, you can't use functions in the Contexts section of the Studio, but you can use functions if you set the Context at the beginning of the job in a tJava or similar. If the first component of the job is a tJava with the expression shown in the first screenshot, then it should work OK.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;context.MyContextVariable = routines.SomeFunction(someParam);&lt;/PRE&gt; 
&lt;P&gt;That would work.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 23:46:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Context-Variable-value-not-working/m-p/2250674#M34858</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-07T23:46:34Z</dc:date>
    </item>
    <item>
      <title>Re: Context Variable value not working</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Context-Variable-value-not-working/m-p/2250675#M34859</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Thanks for your response. Can you explain the solution a little bit more.&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;In the actual job I am using a parameter text file to load the context values. In my job I am not hard coding any context value. I am only defining the context name and call it from a text file.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;So how I can define the numeric (-2) value in a context variable?&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;TalendDate.formatDate("MMyy",(TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),&lt;U&gt;&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;-2&lt;/FONT&gt;&lt;/U&gt;,"MM")))).toString()&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;Because I don't want to touch the job in future, rather I will change the context variable value in&amp;nbsp; the text file.&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;P&gt;I will appreciate if you can give me an example.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 14:46:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Context-Variable-value-not-working/m-p/2250675#M34859</guid>
      <dc:creator>Tasfiahm</dc:creator>
      <dc:date>2019-02-08T14:46:05Z</dc:date>
    </item>
    <item>
      <title>Re: Context Variable value not working</title>
      <link>https://community.qlik.com/t5/Talend-Studio/Context-Variable-value-not-working/m-p/2250676#M34860</link>
      <description>&lt;P&gt;My solution was simply to take your complicated code and apply it in a tJava component at the beginning of your job. So, using some code you used in your previous post, this is how I would assign the value to a context variable in a tJava......&lt;/P&gt; 
&lt;P&gt;&amp;nbsp;&lt;/P&gt; 
&lt;PRE&gt;context.ContextVariableName = TalendDate.formatDate("MMyy",(TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-2,"MM")))).toString();&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Feb 2019 17:04:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Talend-Studio/Context-Variable-value-not-working/m-p/2250676#M34860</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-02-08T17:04:41Z</dc:date>
    </item>
  </channel>
</rss>

