Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing return of fields #10

Closed
alydersen opened this issue Jul 3, 2017 · 11 comments
Closed

Missing return of fields #10

alydersen opened this issue Jul 3, 2017 · 11 comments

Comments

@alydersen
Copy link

alydersen commented Jul 3, 2017

I have this really strange issue that I can't figure out on my own:

When I pull data from the XML-interface of FM directly on one layout, The result is like this:

<record mod-id="1480" record-id="6">
<field name="_id">
<data>SU000005</data>
</field>
<field name="_id_Country">
<data>259</data>
</field>
<field name="DaysWorkdaysInWeek">
<data>5</data>
</field>
<field name="ShortName">
<data>ANS</data>
</field>
</record>

My model for that looks (partially) like this:

  string    :supplier_id, fm_name: '_id', identity: true
  string    :country_id, fm_name: '_id_Country'
  string    :shortname, fm_class: 'ShortName'
  string    :workingdays, fm_class: 'DaysWorkdaysInWeek'

But when I call it, it says nil for the one field (and others that I try to pull like that when I have been playing around to figure it out):
#<Supplier:0x007fb2d0d711a0 @new_record=false, @attributes={"supplier_id"=>"SU000005", "country_id"=>"259.0", "shortname"=>"ANS", "workingdays"=>nil}, @relations={}, @record_id="6", @mod_id="1480", @portals={}>

I only have this problem for one model. Any pointers on what could cause this?

Andreas

@mech
Copy link
Owner

mech commented Jul 3, 2017

Quite strange, what's the data type for DaysWorkdaysInWeek?

Do you have the <metadata> XML where we can inspect, like this?

<metadata>
    <field-definition auto-enter="yes" four-digit-year="no" global="no" max-repeat="1" name="status" not-empty="no" numeric-only="no" result="text" time-of-day="no" type="normal"/>
</metadata>

@alydersen
Copy link
Author

The metadata looks like this:

<metadata>
<field-definition auto-enter="yes" four-digit-year="no" global="no" max-repeat="1" name="_id" not-empty="no" numeric-only="no" result="text" time-of-day="no" type="normal"/>
<field-definition auto-enter="no" four-digit-year="no" global="no" max-repeat="1" name="_id_Country" not-empty="no" numeric-only="no" result="number" time-of-day="no" type="normal"/>
<field-definition auto-enter="yes" four-digit-year="no" global="no" max-repeat="1" name="DaysWorkdaysInWeek" not-empty="no" numeric-only="no" result="number" time-of-day="no" type="normal"/>
<field-definition auto-enter="no" four-digit-year="no" global="no" max-repeat="1" name="ShortName" not-empty="yes" numeric-only="no" result="text" time-of-day="no" type="normal"/>
</metadata>

I have been trying out different data types in the model, but with no change

@mech
Copy link
Owner

mech commented Jul 3, 2017

Your data type for DaysWorkdaysInWeek and _id_Country are both number, maybe you can try number or integer:

  • number are Ruby's BigDecimal under the hood, good for money or floating point
  • integer are just plain integer
string :supplier_id, fm_name: '_id', identity: true
integer :country_id, fm_name: '_id_Country'
string :shortname, fm_class: 'ShortName'
number :workingdays, fm_class: 'DaysWorkdaysInWeek'

Other than that, you can write some debug statement at this file: https://github.com/mech/filemaker-ruby/blob/master/lib/filemaker/metadata/field.rb to see if that help.

@alydersen
Copy link
Author

Thanks for your help so far!

So I made the coerce function output both the value and the datatype, and it returns it just fine:

2.3.4 :006 > Supplier.first
curl -XGET 'https://.../fmi/xml/fmresultset.xml?-db=...&-lay=web__Supplier_Rails&-max=1&-findall=' -i
ETHON: performed EASY effective_url=https://.../fmi/xml/fmresultset.xml response_code=200 return_code=ok total_time=0.021081
SU000005
text
259
number
5
number
ANS
text
SU000005
259.0
ANS
 => #<Supplier:0x007f94cdac9428 @new_record=false, @attributes={"supplier_id"=>"SU000005", "workingdays"=>nil, "country_id"=>"259.0", "shortname"=>"ANS"}, @relations={}, @record_id="6", @mod_id="1480", @portals={}> 

I've changed the data type to number and integer with no effect.
Any more hints?

@mech
Copy link
Owner

mech commented Jul 4, 2017

Are you able to provide me with the whole XML file with your private information removed so that I can put it through the spec to run some test?

@alydersen
Copy link
Author

Here you go:

<fmresultset xmlns="http://www.filemaker.com/xml/fmresultset" version="1.0">
  <error code="0"/>
  <product build="4/5/2017" name="FileMaker Web Publishing Engine" version="16.0.1.184"/>
  <datasource database="..." date-format="MM/dd/yyyy" layout="web__Supplier_Rails" table="..." time-format="HH:mm:ss" timestamp-format="MM/dd/yyyy HH:mm:ss" total-count="161"/>
  <metadata>
    <field-definition auto-enter="yes" four-digit-year="no" global="no" max-repeat="1" name="_id" not-empty="no" numeric-only="no" result="text" time-of-day="no" type="normal"/>
    <field-definition auto-enter="no" four-digit-year="no" global="no" max-repeat="1" name="_id_Country" not-empty="no" numeric-only="no" result="number" time-of-day="no" type="normal"/>
    <field-definition auto-enter="yes" four-digit-year="no" global="no" max-repeat="1" name="DaysWorkdaysInWeek" not-empty="no" numeric-only="no" result="number" time-of-day="no" type="normal"/>
    <field-definition auto-enter="no" four-digit-year="no" global="no" max-repeat="1" name="ShortName" not-empty="yes" numeric-only="no" result="text" time-of-day="no" type="normal"/>
  </metadata>
  <resultset count="161" fetch-size="2">
    <record mod-id="1480" record-id="6">
      <field name="_id">
        <data>SU000005</data>
      </field>
      <field name="_id_Country">
        <data>259</data>
      </field>
      <field name="DaysWorkdaysInWeek">
        <data>5</data>
      </field>
      <field name="ShortName">
        <data>ANS</data>
      </field>
    </record>
    <record mod-id="1390" record-id="7">
      <field name="_id">
        <data>SU000006</data>
      </field>
      <field name="_id_Country">
        <data>243</data>
      </field>
      <field name="DaysWorkdaysInWeek">
        <data>5</data>
      </field>
      <field name="ShortName">
        <data>CCE</data>
      </field>
    </record>
  </resultset>
</fmresultset>

@mech
Copy link
Owner

mech commented Jul 4, 2017

Oh FileMaker 16. I do not have it. I only have FM 15. I may need to upgrade first. Probably something changed between the version. I will test it regardless and let you know the outcome.

@alydersen
Copy link
Author

Want me to create a user for you on our system for testing purposes?

@mech
Copy link
Owner

mech commented Jul 4, 2017

Oh better not for sec and privacy concern. The XML file should be enough :)

@alydersen
Copy link
Author

alydersen commented Jul 4, 2017

I'm so sorry, but this is a typo on my end. In the model, I'v managed to type fm_class instead of fm_name. It worked beautifully when I changed that.

Sorry again for the trouble caused!

Andreas

@mech
Copy link
Owner

mech commented Jul 5, 2017

Oooo.. great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants