3 Replies Latest reply on Sep 23, 2011 8:17 AM by philmodjunk

    Create new value and displaying it in another layout

    DennisvanBurik

      Title

      Create new value and displaying it in another layout

      Post

      Hello,

      First i will subscribe my situation to clarify my question.
      I have 3 tables: Customer; Customer_Company; Company.
      When i'm in the Customer layout i want the opportunity to link him to a company.
      But if the company where his working isn't present in the Company records, I can click on a button "New Company" that creates a new record in the company table.

      That works so far, but i also want that the CompanyID automatically is filled in the portaltool.
      The script i'm now using for the button is:

      Go to Lay-out ["Company" (Company)]
      New record/new request
      Go to Lay-out ["Customer"(Customer)]
      Go to field [Customer_Company::CompanyID]
      Set Field [Customer_Company::CompanyID; GetNthRecord ( Customer_Company::CompanyID ; +1)]

      My Question is: What do i have to change or what am i doing wrong?

      Answering this question can in Dutch (Nederlands) or in Englisch.

        • 1. Re: Create new value and displaying it in another layout
          philmodjunk

          Freeze window
          Set Variable [$CustomerID ; value: Customer::CustomerID ]
          Go to Lay-out ["Company" (Company)]
          New record/new request
          Set Variable [$CompanyID ; value: Company::CompanyID]
          Go to Lay-out ["Customer_Company"(Customer_Company)]
          New Record/Request
          Set Field [Customer_Company::CompanyID ; $CompanyID]
          Set Field [Customer_Company::CustomerID ; $CustomerID]
          Go To Layout [original layout]

          This way you create a new company record and then also a matching Customer_Company record that links the current record on your Customer Layout to that new company record. If you have fields from Company in your Customer_Company portal and permit entry into them while in Browse mode, you can click your new company button and then fill in the fields in the new row that appears in this portal.

          • 2. Re: Create new value and displaying it in another layout
            DennisvanBurik

            Thanks, but now i get a error that the field Customer_Company::CustomerID can't be empty.
            If i say that it's allowed to skip the field i don't get the result i was looking for.
            How do i solve this?

            • 3. Re: Create new value and displaying it in another layout
              philmodjunk

              That error message should not be appearing as That field gets a value in the 8th line of the script.

              Make sure that this script is run from the Customer layout not the company or customer_company layout. Make sure that the current record on that layout is the one to which you want to link the new join record and new company record.

              Line 2 captures the CustomerID of the current customer record in a variable and in line 8 puts it in the join table.