1 Reply Latest reply on Oct 15, 2012 7:40 AM by philmodjunk

    Script Help

    Annette

      Title

      Script Help

      Post

            Hi,

           Sorry if this is simple, I'm learning scripts at the moment. 

           I have layout which contains a portal from EOC's.  On the portal row I have a button which I would like to take me to a different layout which shows the Service Activity for that EOC on a portal.  (The relationship is made by EOCID and I have it ticked to allow new records via this relationship in Service Activity)

           At the moment the script on that button does the following:

             
      •           If [not ( IsEmpty ( EOC::EOCID ) )]
      •      
      •           Go to related record [Show only related records; from table: "Service Activity"; using layout; "Service Activity" (Service Activity)
      •      
      •           Show / Hide Status Area [Lock; Hide]
      •      
      •           Pause / Resume Script [ Indefinitely]
      •      
      •           Show / Hide Status Are [Show]
      •      
      •           Go To Layout [original layout]
      •      
      •           End if

           That's works fine, IF there is already a Service Activity there.  But, what I would like to do if there hasn't been a service activity created yet for this EOC to allow me to create a new record request. 

           It just seems whatever way I'm doing this I'm doing it wrong.  Either it adds a new record to the wrong area (client) or doesn't work at all.  I'm not sure if I've done the layout info wrong either, ie the Service Activity layout shows records from the Service Activity table

        • 1. Re: Script Help
          philmodjunk

               I am assuming that EOC is listed in Layout Setup | "Show Records From" and that "Service Activity" is what is listed in Portal Setup | "Show Related Records From".

               If so, you script should be:

               If [not ( IsEmpty ( Service Activity::EOCID ) )]
                      Go to related record [Show only related records; from table: "Service Activity"; using layout; "Service Activity" (Service Activity)
                      Show / Hide Status Area [Lock; Hide]
                      Pause / Resume Script [ Indefinitely]
                      Show / Hide Status Are [Show]
                      Go To Layout [original layout]
               Else
                     Show Custom Dialog ["Create a new Service Activity Record?"]
                     If [ Get ( LastMessageChoice ) = 1 // Button 1, OK, was clicked]
                        Freeze Window
                        Set Variable [$EOCID ; value: EOC::EOCID]
                        Go to Layout [ "Service Activity" ( Service Activity ) ]
                        New Record/Request
                        Set Field [Service Activity::EOCID ; $EOCID]
                        Go To Layout [Original Layout]
               End if

               If you need to remain on the Service Activity layout in order to enter data in other fields in the new record, remove the red script step.