Announcement

Collapse
No announcement yet.

Set Asset Default Contract via API

Collapse
X
 
  • Filter
  • Time
Clear All
new posts

    Set Asset Default Contract via API

    A large number of assets were created with a default contract as a specific contract and not as a series contract.

    There is nothing in the API documentation about how to set this. Looking at an Asset object in the debugger, I don't see anything related to contracts.

    In the raw database table for Assets I can see a CONTRACTRECID field, shows a normal contract RecID for a specific, and an asterisk-prefixed code that I presume is found in the BContractSeries table but I can't locate a matching record.

    Any advice will be much appreciated!

    Re: Set Asset Default Contract via API

    Follow-up: I found I can do this --

    asset.SetFieldValue("FLDASTCONTRACTID", contract.ContractID)

    But that is setting it as a specific contract. What's the equivalent for series?

    Comment


      Re: Set Asset Default Contract via API

      Thank you for posting this.

      Once the Contract Series is set to the Asset, field FLDASTCONTRACTID is populated with a value from Contract.SEQID field - prefixed with asterisk.

      The Contracts.SEQID (without the asterisk) equals to BContractSeries.SEQID.

      Hope this helps.

      Comment


        Re: Set Asset Default Contract via API

        Thanks, I'll give this a try. My confusion here is that while I see the SeqID in the BContracts table and can get to it via the specific contract RecID, I cannot find the SeqID in the BContractSeries table.

        Comment


          Re: Set Asset Default Contract via API

          SEQID is the unique / key field in the BContractsSeries, like RECID in other tables.
          This value groups all contract-instances belonging to the same series.

          Using the BContracts.SEQID field should work for you.

          Hope this helps.

          Comment


            Re: Set Asset Default Contract via API

            Sure, will give it a try. My concern is that the query below yields six records that are all part of this series, as expected. So clearly it's a legit SeqID

            select * from bcontracts where seqid = 'ZVDXHL6HO28AMPQ9VQ4H'

            However, this next query returns zero records and I was expecting to see exactly one.

            select * from bcontractseries where seqid = 'ZVDXHL6HO28AMPQ9VQ4H'

            I'll work on the API code this morning and hopefully it'll "just work" and I don't need to solve the mystery of the bcontractseries table.

            Comment


              Re: Set Asset Default Contract via API

              The record is added to BContractSeries table only if the Contract is set to auto-renew.

              Hope it helps and makes sense.

              Comment


                Re: Set Asset Default Contract via API

                Got it, that makes sense.

                Almost have this API code running but there's zero documentation on Contracts in the API references. I have successfully fetched a contract object and now need to extract the SeqID from it. There's no SeqID property on the object so I'll need the field name for the Get as illustrated below.

                SeqID = contract.GetFieldValue("??")

                If this actually is documented somewhere I'd be happy to go there and discover all of this.

                Comment


                  Re: Set Asset Default Contract via API

                  Yep, unlike other areas, there is no documentation*for the working-but-still-unofficial Contracts API. It's on our list and be publicly available once we announce it officially.

                  Please use FLDBCTSEQID.

                  Hope this helps.

                  Comment


                    Re: Set Asset Default Contract via API

                    I guessed that FLDBCTSEQID might be the name, based on experience with other objects. It's always blank. Argh -- now I am getting it, that field is not part of the default set of values that are returned from queries. I'm making progress!

                    Comment


                      Re: Set Asset Default Contract via API

                      Success, I'm able to set assets with a specific contract to a series contract. This is based on running a series of single record test cases.

                      However, in a batch mode for some (not all) assets I get an error saying that the Type and Name fields are required when I call the asset.Save() method. Looking in the debugger, there are values for both in the asset object.

                      This error is off-topic for this thread so let me know if I should create a new thread.

                      Comment


                        Re: Set Asset Default Contract via API

                        Great!!!

                        Regarding the other item, please share the logs files with us over email, hopefully we'll learn what in the API call returns this message.

                        Comment


                          Re: Set Asset Default Contract via API

                          Log files in a .zip are heading your way. The error occurred during an asset.Save() call if that helps narrow it down.

                          Comment

                          Working...
                          X