5 Replies Latest reply on Mar 7, 2012 2:42 PM by philmodjunk

    Help with relational button script

    JaredEkas

      Title

      Help with relational button script

      Post

      Hi,

      I have two tables.  Opportunities and Quotes.  Opportunities has a parent key of (k_ID_Opportunity)  Quotes has a child key of (kf_ID_Opportunity)  These have a one to many relationship 1 opp to many quotes.

      In my opportunity Record Detail, i have sucessfully inserted a portal which displays only the related quotes.  Where my issue lies is i am trying to create a button which lets you create a new quote, and relate it to the current opportunity without having to manually populate the (kf_ID_Opportunity) field in the quote detail.

      So far i have only been able to create a new quote, but i cant get it to populate the child key to match the opportunity which the button is pressed in the opportunity from.   Here is my code, i have mixed this around with no luck.   Please help me with whats wrong.

      Set Variable [$ID_Opportunity; Value:Opportunities::k_ID_Opportunity

      Go To Layout [Quote Detail" (Quotes)]

      New Record/Request

      Set Field [Quotes::kf_ID_Opportunity; $ID_Opportunities]

      Commit Records/Requests [No dialog]

      Go to Next Field

      im guessing the issue is in the SET FIELD section, but have tried a couple combos and cant get it to work.

      THANKS FOR THE HELP!

      Jared


        • 1. Re: Help with relational button script
          philmodjunk

          Opportunities::k_ID_Opportunity = Quotes::kf_ID_Opportunity

          Please note, you can also create new Quotes records directly in your portal if you select "allow creation of records via this relationship" for Quotes in the above relationship.

          Your script looks correct except for a real picky detail.

          In line one, the variable is named $ID_Opportunity. In line two, you refer to a different variable: $ID_Opportunities

          change $ID_Opportunities to $ID_Opportunity and it should work for you.

          • 2. Re: Help with relational button script
            JaredEkas

            Thanks!

            I will try this later and confirm.  On the "you can also create new Quotes records directly in your portal if you select "allow creation of records via this relationship" for Quotes in the above relationship."

            Is this done on the script, or in the relationship properties?


            • 3. Re: Help with relational button script
              philmodjunk

              It's a relationship property. You open manage | Database | Relationships, find the relationship line for the relationship on which your portal is based and double click it to bring up a dialog box where this option may be selected. Once you have selected it, you can create new related records by entering data into any field in the bottom blank "add" row of your portal. This isn't always a convenient way to add related records as you have to scroll your portal to what might be a long list of existing related records each time you add a new quote so you may find that the button is still a better way to go--especially if you set up sorting on your portal rows so that the newest quote is listed first instead of last.

              • 4. Re: Help with relational button script
                JaredEkas

                Ok.  That was it!  I looked at that darn thing over and over and did not catch that.

                Last question.. "today"...    Both Tables also have a Title Field these fields are not currently related.

                Is it possible to modify the script to also carry over the title field from the Opportunity to the Quote, although retaining the true "relationship" to be the kf_ID_Opportunity.

                 

                I played with this and got it to work where it imported the Title into both the KF & Title fields, and also the Opp_ID in both fields, but cant seem to split them correctly.

                Thanks Again for your great help!

                • 5. Re: Help with relational button script
                  philmodjunk

                  Do you really need the field to be in both tables?

                  Any layout or portal based on Quotes can simply use the field from Opportunities to display this data. Just add the field from Opportunities to the layout or portal row and the related record in Opportunities will supply the Title.