2 Replies Latest reply on Mar 27, 2015 12:47 AM by ManjitSandhu

    Why Does Script Not Populate Field?

    ManjitSandhu

      Title

      Why Does Script Not Populate Field?

      Post

      OK, so in my ongoing support of this application, I've been asked to make a change to populate a field based on previously selected item. It seemed straightforward, and as far as i can tell, I have done everything right, but the field will not accept the new value.

      So on the field that triggers the update, I've added the following script to the ObjectModify event:
      Set Error Capture [On]
      // Show Custom Dialog["Source Field"; Client_SCHEME::d_Oracle_Code]
      Set Field[Client_Activity_SCHEME::d_Oracle_Code;Client_SCHEME::d_Oracle_Code]
      // Show Custom Dialog["Target Field"; Client_Activity_SCHEME::d_Oracle_Code]

      If I enable both 'Show Custom Dialog' lines, I get a result for the first one, but the second one remains blank.

      The target field (Client_Activity_SCHEME::d_Oracle_Code) is an indexed text field, so I can't see why it won't populate. The properties for the target field on the layout are Edit Box with Browse mode unticked, and 'Display Data From' is set to Client_Activity_SCHEME::d_Oracle_Code.

      With Script debugging on, the script runs, the messages show, first with a result, second with nothing, but that's it. I know it's not going to be obvious from what I have given, but wanted to make sure it's not something obvious to a novice like me!

      Thanks

      Martin

        • 1. Re: Why Does Script Not Populate Field?
          philmodjunk

          What layout are you on when the script runs? What table is it based on?

          Set Field[Client_Activity_SCHEME::d_Oracle_Code;Client_SCHEME::d_Oracle_Code]

          Refers to two different Tutorial: What are Table Occurrences?: Client_Activity_SCHEME and Client_SCHEME

          One, the other or both are apparently not accessible from the context of your current layout. This will be controlled by:

          1) What table occurrence is selected in Layout Setup | Show Records From for the current layout

          2) What relationships link that table occurrence to other table occurrences in your relationship graph, such as the two referenced in your set field step.

          3) the values in any match fields of the current record on your layout.

          A common mistake here is that a developer will set up a script to create a new record and then can't see why a subsequent set field step fails to modify a field, not realizing that a new record may have empty match fields and thus not have any links to records in related tables from which to reference one or the other table occurrences in the set field step.

          • 2. Re: Why Does Script Not Populate Field?
            ManjitSandhu

            Thanks for your reply.

            After reading your reply, and running it again, I noted on the script debugger am getting an error 103, so it does indeed look like the relationship is missing/incorrect. I will investigate further, but appreciate your reply.

            Thanks

            Martin