<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.method.me/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Method:API Q&amp;A</title><link>http://forums.method.me/cs/forums/15.aspx</link><description>Ask questions specific to the MethodAPI from the Method Team and other Method users.</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 SP2 (Build: 31113.47)</generator><item><title>Re: Writing two linked tables</title><link>http://forums.method.me/cs/forums/thread/13203.aspx</link><pubDate>Wed, 18 Jul 2012 15:33:10 GMT</pubDate><guid isPermaLink="false">3393c1ec-311b-4812-96cb-ad8c611bba4f:13203</guid><dc:creator>Method_David</dc:creator><slash:comments>0</slash:comments><comments>http://forums.method.me/cs/forums/thread/13203.aspx</comments><wfw:commentRss>http://forums.method.me/cs/forums/commentrss.aspx?SectionID=15&amp;PostID=13203</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Hi Jason L,&lt;/p&gt;
&lt;p&gt;Glad to hear you got it working. I&amp;#39;ve been trying to reproduce the error for the past 2 days without any luck. I was actually starting to write a post asking you to elaborate on how you set up your linked fields.&lt;/p&gt;
&lt;p&gt;Dave&lt;/p&gt;</description></item><item><title>Re: Writing two linked tables</title><link>http://forums.method.me/cs/forums/thread/13201.aspx</link><pubDate>Wed, 18 Jul 2012 15:17:46 GMT</pubDate><guid isPermaLink="false">3393c1ec-311b-4812-96cb-ad8c611bba4f:13201</guid><dc:creator>Jason_L</dc:creator><slash:comments>0</slash:comments><comments>http://forums.method.me/cs/forums/thread/13201.aspx</comments><wfw:commentRss>http://forums.method.me/cs/forums/commentrss.aspx?SectionID=15&amp;PostID=13201</wfw:commentRss><description>&lt;p&gt;I finally got this to work. I needed to add a linked field along with the drop down, then not pass any parameters to the insert call dealing with the linked field. I was counting on the dropdown to hold Table A&amp;#39;s record ID, but I had to add an actual linked field to the record ID, and then it worked. Thanks for the help.&lt;/p&gt;</description></item><item><title>Re: Writing two linked tables</title><link>http://forums.method.me/cs/forums/thread/13187.aspx</link><pubDate>Mon, 16 Jul 2012 21:47:15 GMT</pubDate><guid isPermaLink="false">3393c1ec-311b-4812-96cb-ad8c611bba4f:13187</guid><dc:creator>Jason_L</dc:creator><slash:comments>0</slash:comments><comments>http://forums.method.me/cs/forums/thread/13187.aspx</comments><wfw:commentRss>http://forums.method.me/cs/forums/commentrss.aspx?SectionID=15&amp;PostID=13187</wfw:commentRss><description>&lt;p&gt;That was the original failing case. The field in Table B that is linked to Table A&amp;#39;s record ID cannot be written if I write a new row to table A and then pull the record ID from that new row. It appears that Table B does not know that the record ID for the new row is valid, and so balks at my insert. For example (using brief pseudo code)&lt;/p&gt;
&lt;p&gt;MethodAPI.MethodAPIInsertV2(all the right stuff, writing a new row to table a)&lt;/p&gt;
&lt;p&gt;MethodAPI.MethodAPISelect_XMLV2(get table A record Id for new row)&lt;/p&gt;
&lt;p&gt;MethodAPI.MethodAPIInsertV2(writing to Table B, including the result from the line above) &amp;lt;-Failure&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Writing two linked tables</title><link>http://forums.method.me/cs/forums/thread/13183.aspx</link><pubDate>Mon, 16 Jul 2012 21:31:07 GMT</pubDate><guid isPermaLink="false">3393c1ec-311b-4812-96cb-ad8c611bba4f:13183</guid><dc:creator>Method_David</dc:creator><slash:comments>0</slash:comments><comments>http://forums.method.me/cs/forums/thread/13183.aspx</comments><wfw:commentRss>http://forums.method.me/cs/forums/commentrss.aspx?SectionID=15&amp;PostID=13183</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Jason L,&lt;/p&gt;
&lt;p&gt;Sorry to keep you waiting...it&amp;#39;s been kinda a manic Monday....anyway...&lt;/p&gt;
&lt;p&gt;It sounds like you&amp;#39;ve added an extra field for recordid to table B, and have made it required. So it should be part of your insert list. &lt;/p&gt;
&lt;p&gt;Extending my example from above&lt;/p&gt;
&lt;p&gt;&amp;nbsp;string[ arrInsertFieldsArray = new string[ { &amp;quot;ArAccount&amp;quot;, &amp;quot;Customer&amp;quot;, &amp;quot;TxnDate&amp;quot;, &amp;quot;MyExtraRecordIDField&amp;quot;&amp;nbsp;};&lt;/p&gt;
&lt;p&gt;string[ arrInsertValueArray = new string[ { &amp;quot;Accounts Receivable&amp;quot;, &amp;quot;Amy Smith&amp;quot;, &amp;quot;13/july/2012&amp;quot;, &amp;quot;5&amp;quot;&amp;nbsp;};&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;lblMethodAPIInsertV2.Text = _MethodAPI.MethodAPIInsertV2(CompanyAccount, Login, Password,&amp;quot;&amp;quot;, &amp;quot;Invoice&amp;quot;, arrInsertFieldsArray, arrInsertValueArray);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Dave&lt;/p&gt;</description></item><item><title>Re: Writing two linked tables</title><link>http://forums.method.me/cs/forums/thread/13181.aspx</link><pubDate>Mon, 16 Jul 2012 20:50:52 GMT</pubDate><guid isPermaLink="false">3393c1ec-311b-4812-96cb-ad8c611bba4f:13181</guid><dc:creator>Jason_L</dc:creator><slash:comments>0</slash:comments><comments>http://forums.method.me/cs/forums/thread/13181.aspx</comments><wfw:commentRss>http://forums.method.me/cs/forums/commentrss.aspx?SectionID=15&amp;PostID=13181</wfw:commentRss><description>&lt;p&gt;I&amp;#39;m just pinging on this. If I&amp;#39;m going about table construction or insertion wrong, please let me know. Thanks.&lt;/p&gt;</description></item><item><title>Re: Writing two linked tables</title><link>http://forums.method.me/cs/forums/thread/13156.aspx</link><pubDate>Fri, 13 Jul 2012 20:34:42 GMT</pubDate><guid isPermaLink="false">3393c1ec-311b-4812-96cb-ad8c611bba4f:13156</guid><dc:creator>Jason_L</dc:creator><slash:comments>0</slash:comments><comments>http://forums.method.me/cs/forums/thread/13156.aspx</comments><wfw:commentRss>http://forums.method.me/cs/forums/commentrss.aspx?SectionID=15&amp;PostID=13156</wfw:commentRss><description>&lt;p&gt;That is a dropdown in Table B that is pulled in from Table A. I&amp;#39;m trying to keep B synced with A, via A&amp;#39;s record ID.&lt;/p&gt;</description></item><item><title>Re: Writing two linked tables</title><link>http://forums.method.me/cs/forums/thread/13153.aspx</link><pubDate>Fri, 13 Jul 2012 20:23:12 GMT</pubDate><guid isPermaLink="false">3393c1ec-311b-4812-96cb-ad8c611bba4f:13153</guid><dc:creator>Method_David</dc:creator><slash:comments>0</slash:comments><comments>http://forums.method.me/cs/forums/thread/13153.aspx</comments><wfw:commentRss>http://forums.method.me/cs/forums/commentrss.aspx?SectionID=15&amp;PostID=13153</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Jason L&lt;/p&gt;
&lt;p&gt;I need a little more information about this.&lt;/p&gt;
&lt;p&gt;&amp;quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;windows-1252&amp;quot; ?&amp;gt;&amp;lt;MethodAPI response = &amp;quot;Cannot insert the value NULL into column &amp;#39;TableARecordID&amp;#39;, table &amp;#39;xxx.dbo.TableB&amp;#39;; column does not allow nulls. INSERT fails.&amp;quot;&lt;/p&gt;
&lt;p&gt;Is &amp;#39;TableARecordID&amp;#39; a custom field? aka a field defined by you? All tables created in method have a&amp;nbsp;recordid&amp;nbsp;field in&amp;nbsp;them automatically. If you have created your own &amp;quot;recordid&amp;quot;&amp;nbsp;field and made it required. The above code will not populate it.&lt;/p&gt;
&lt;p&gt;Dave&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Writing two linked tables</title><link>http://forums.method.me/cs/forums/thread/13152.aspx</link><pubDate>Fri, 13 Jul 2012 19:46:29 GMT</pubDate><guid isPermaLink="false">3393c1ec-311b-4812-96cb-ad8c611bba4f:13152</guid><dc:creator>Jason_L</dc:creator><slash:comments>0</slash:comments><comments>http://forums.method.me/cs/forums/thread/13152.aspx</comments><wfw:commentRss>http://forums.method.me/cs/forums/commentrss.aspx?SectionID=15&amp;PostID=13152</wfw:commentRss><description>&lt;p&gt;I&amp;#39;ve just tried that, and it doesn&amp;#39;t seem to be working. Here&amp;#39;s a code snippet that I&amp;#39;ve got (with correct variables and all), it&amp;#39;s Java syntax, but not tough to follow: &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private static final String[ METHOD_TABLE_A_FIELDS_TO_WRITE = 
{&amp;quot;Company&amp;quot;, &amp;quot;Email&amp;quot;, &amp;quot;NameFirst&amp;quot;, &amp;quot;NameLast&amp;quot;, &amp;quot;NameFull&amp;quot;,&amp;nbsp; &amp;quot;Notes&amp;quot;};&lt;/p&gt;
&lt;p&gt;private static final String[ METHOD_TABLE_B_FIELDS_TO_WRITE = {&amp;quot;NameFirst&amp;quot;, &amp;quot;NameLast&amp;quot;, &amp;quot;NameFull&amp;quot;, &amp;quot;email&amp;quot;};&lt;/p&gt;
&lt;p&gt;private static String[ methodTableAValuesToWrite = {&amp;quot;Slappy, Inc.&amp;quot;, &amp;quot;slappy@mcgee.net&amp;quot;, &amp;quot;AAAA&amp;quot;, &amp;quot;AAAA&amp;quot;, &amp;quot;AAAA AAAA&amp;quot;, &amp;quot;This is a test item&amp;quot;};&lt;/p&gt;
&lt;p&gt;private static String[ methodTableBValuesToWrite = {&amp;quot;AAAA&amp;quot;, &amp;quot;AAAA&amp;quot;, &amp;quot;AAAA AAAA&amp;quot;, &amp;quot;slappy@mcgee.net&amp;quot;};&lt;/p&gt;
&lt;p&gt;...&lt;/p&gt;
&lt;p&gt;String response = service.methodAPIInsertV2(METHOD_COMPANY_NAME, METHOD_USER_NAME, METHOD_USER_PASSWORD, &amp;quot;&amp;quot;, METHOD_TABLE_A_NAME, METHOD_TABLE_A_FIELDS_TO_WRITE, methodTableAValuesToWrite );&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(response);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; response = service.methodAPIInsertV2(METHOD_COMPANY_NAME,METHOD_USER_NAME, METHOD_USER_PASSWORD, &amp;quot;&amp;quot;, METHOD_TABLE_B_NAME, METHOD_TABLE_B_FIELDS_TO_WRITE, methodTableBValuesToWrite);&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(response);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My sysout calls show me:&lt;/p&gt;
&lt;p&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;windows-1252&amp;quot; ?&amp;gt;&amp;lt;MethodAPI response = &amp;quot;Success&amp;quot; RecordID=&amp;quot;2331&amp;quot; &amp;gt;&amp;lt;/MethodAPI&amp;gt;&lt;br /&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;windows-1252&amp;quot; ?&amp;gt;&amp;lt;MethodAPI response = &amp;quot;Cannot insert the value NULL into column &amp;#39;TableARecordID&amp;#39;, table &amp;#39;xxx.dbo.TableB&amp;#39;; column does not allow nulls. INSERT fails.&lt;br /&gt;The statement has been terminated.&amp;quot; &amp;gt;&amp;lt;/MethodAPI&amp;gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So it looks to me that the API is automatically inserting null into the linked field, and so my insert is failing. The field is required, and I can try removing that restriction if the field will be updated by a chron job or something at a later time. If not, there&amp;#39;s still something missing in this operation. By the way, if I add a known good record ID from table A (I used 1) to the values array, I get a success message.&lt;/p&gt;</description></item><item><title>Re: Writing two linked tables</title><link>http://forums.method.me/cs/forums/thread/13142.aspx</link><pubDate>Fri, 13 Jul 2012 17:37:20 GMT</pubDate><guid isPermaLink="false">3393c1ec-311b-4812-96cb-ad8c611bba4f:13142</guid><dc:creator>Method_David</dc:creator><slash:comments>0</slash:comments><comments>http://forums.method.me/cs/forums/thread/13142.aspx</comments><wfw:commentRss>http://forums.method.me/cs/forums/commentrss.aspx?SectionID=15&amp;PostID=13142</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Hi Jason L,&lt;/p&gt;
&lt;p&gt;In the second scenario, you don&amp;#39;t need to use the recordid after the insert, just the text to write to B. This is because currently the api does a look up internally and grabs the recordid.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll illustrate this with an example (It&amp;#39;s in C# and assumes you have all the references, etc added). I want to insert an invoice into my account. For brevity, I only want to insert into the required fields, ArAccount, Customer, and TxnDate. For ArAccount I want to insert Accounts Receivable (RecordID 5), the customer is Amy Smith (RecordID 19), and for TxnDate I&amp;#39;ll use today&amp;#39;s date&lt;/p&gt;
&lt;p&gt;The following will &lt;strong&gt;not&lt;/strong&gt; work&lt;/p&gt;
&lt;p&gt;string[ arrInsertFieldsArray = new string[ { &amp;quot;ArAccount&amp;quot;, &amp;quot;Customer&amp;quot;, &amp;quot;TxnDate&amp;quot; };&lt;/p&gt;
&lt;p&gt;string[ arrInsertValueArray = new string[ { &lt;strong&gt;&amp;quot;5&amp;quot;, &amp;quot;19&amp;quot;&lt;/strong&gt;, &amp;quot;13/july/2012&amp;quot; };&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;lblMethodAPIInsertV2.Text = _MethodAPI.MethodAPIInsertV2(CompanyAccount, Login, Password,&amp;quot;&amp;quot;, &amp;quot;Invoice&amp;quot;, arrInsertFieldsArray, arrInsertValueArray);&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The following will work&lt;/p&gt;
&lt;p&gt;string[ arrInsertFieldsArray = new string[ { &amp;quot;ArAccount&amp;quot;, &amp;quot;Customer&amp;quot;, &amp;quot;TxnDate&amp;quot; };&lt;/p&gt;
&lt;p&gt;string[ arrInsertValueArray = new string[ {&lt;strong&gt; &amp;quot;Accounts Receivable&amp;quot;, &amp;quot;Amy Smith&amp;quot;&lt;/strong&gt;, &amp;quot;13/july/2012&amp;quot; };&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/p&gt;
&lt;p&gt;lblMethodAPIInsertV2.Text = _MethodAPI.MethodAPIInsertV2(CompanyAccount, Login, Password,&amp;quot;&amp;quot;, &amp;quot;Invoice&amp;quot;, arrInsertFieldsArray, arrInsertValueArray);&lt;/p&gt;
&lt;p&gt;Dave&lt;/p&gt;</description></item><item><title>Writing two linked tables</title><link>http://forums.method.me/cs/forums/thread/13136.aspx</link><pubDate>Fri, 13 Jul 2012 15:45:39 GMT</pubDate><guid isPermaLink="false">3393c1ec-311b-4812-96cb-ad8c611bba4f:13136</guid><dc:creator>Jason_L</dc:creator><slash:comments>0</slash:comments><comments>http://forums.method.me/cs/forums/thread/13136.aspx</comments><wfw:commentRss>http://forums.method.me/cs/forums/commentrss.aspx?SectionID=15&amp;PostID=13136</wfw:commentRss><description>&lt;p&gt;I have two tables, A and B, with a dropdown field in B that links to the automatically generated RecordID in A. I want to write to B and link it to A at the same time.&lt;/p&gt;
&lt;p&gt;Through the API, my program flow works like this:&lt;/p&gt;
&lt;p&gt;Take a variable passed in as an argument, and look that up in A, using methodAPISelect_XMLV2. &lt;/p&gt;
&lt;p&gt;1) If I have a record ID, then I add that to the values being written into B using methodAPIInsertV2.&lt;/p&gt;
&lt;p&gt;2) Else, I write details into A and then fetch the record ID from the field just written. Then add that record ID to the values being added to B.&lt;/p&gt;
&lt;p&gt;Situation 1 works very well. Situation 2 does not work. The response shows the API balking on the recordID insert. I think, given other forum posts that it could be that the record just written into A hasn&amp;#39;t had time to propigate into A-&amp;gt;B lookup table, and so B doesn&amp;#39;t understand that the new record does exist in A.&lt;/p&gt;
&lt;p&gt;So, do I need to manually write the record ID into a middle lookup table somewhere, or do I need to make my program sleep for a little while to give A time to propigate its new value? If I need to write that record ID into a lookup table, how can I find the name of that table? It doesn&amp;#39;t seem like something that would be exposed.&lt;/p&gt;</description></item></channel></rss>