3 Replies Latest reply on Nov 7, 2016 2:18 PM by DavidCushworth

    Automatically Entering a Record from a Script.

    DavidCushworth

      I have a database of contacts (Name of the DB is "Sponsors"), usual stuff:  Record ID & personal details as nauseam.

       

      I have a database (name of the DB is "Sponsors Log") that records what communications we have with each contact.  Three fields:  Record ID of the contact , Date, Comments.

       

      The comments are viewed in a Portal on the customer Layout.

       

      I have them in a relationship connected between the Record ID's in each database.    I have permissions set to allow the Sponsors Log DB to be changed from within the portal.

       

      I then have a pre-defined e-mail we send to the contacts, using a script.     Part of the script is meant to make an entry into the Comments DB showing the date & description of the email sent.

       

      I Screen Shot 2016-11-07 at 4.02.47 PM.png

      The record is created successfully, the data for the date & Comments is there, but for some reason the Record ID is not being recorded.  I get 2 out 3, with the most important one being omitted.

       

      In the Sponsors Log DB, the field I use for the Record ID (actual Name Sponsor ID) is just an indexed Number.    I have tried it with a calculated value but nothing seems to work.

       

      It should be an extremely simple thing, but for reason I can't get it to work.

       

      Help !!

       

      Thanks

        • 1. Re: Automatically Entering a Record from a Script.
          BruceRobertson

          1. What is Sponsors Record#? You mention SponsorID but that does not appear to be it.

          2. Do not use # in a field name.

          3. You just created a new Log record. Therefore any attempt to use a related field will fail because there NO related fields at this point.

          4. At the start of the script set a variable with SponsorID. Set fkSponsorID of the new log record to this variable.

          3 of 3 people found this helpful
          • 2. Re: Automatically Entering a Record from a Script.
            erolst

            The issue here is that you cannot set the ID to the related value because it's that very ID itself that required to establish the relationship – a sort of Catch-22.

             

            Add this step to your script (before you go to to the Sponsors Log layout):

             

            Set Variable [ $sponsorID ; Sponsors::Record # ]

             

            and change the second line above to

             

            Set Field [ Sponsors Log::Sponsor ID ; $sponsorID ]

             

            Note that it pays to be clear and consistent in your nomenclature. 'Record #' implies a record's Record Number which is something very different from the unique primary key. Why not use (something along the lines of) ID for Sponsors and sponsorID for Sponsors Log?

            3 of 3 people found this helpful
            • 3. Re: Automatically Entering a Record from a Script.
              DavidCushworth

              Bingo !!     The variable did it.

               

              Many thanks indeed.