Ir al contenido principal

Launching Pop-Up Windows and Passing Data in Sage X3

There are occasions in X3 where we need to launch a pop-up dialog box from a button and pass data from the source screen to the pop-up window. This can easily be accomplished with a combination of a screen, window and an action and a bit of code.
In this demonstration, I’ll set up a pop-up window to display information about a supplier that a purchase order has been raised for.

Creating the Screen

Firstly, we’ll need to create a new screen. This will be used to combine the fields we want to display in the window.
Navigate to Development -> Script Dictionary -> Screens
Create a new screen with the fields required.
Set up a new screen with the screen code ZPOHBPS and the size set to Dialogue. Add the sections and fields necessary to be displayed in the window, such as supplier name, contact details and address fields. Save and validate.

Creating the Window

The above screen will be used within a new window, which will be shown to the user when they click on the button. Let’s create the new window.
Navigate to Development -> Script Dictionary -> Windows
Create a new window with a link to the screen.
Create a new window, setting the window type to Sundry/Miscellaneous and the display to Dialogue box. Under the Tabs section, add the screen that was created above and keep the rest of the values the same. Save and validate.

Creating the Action

The action we create will be responsible for passing the data from the source screen to the window through parameters, and also run the code we write to populate the fields.
Navigate to Development -> Script Dictionary -> Actions
Set up a new window entry action and provide a specific script.
Set the template to Window entry and the type to Miscellaneous. Tab down to the Main Window field and type ZPOHBPS to set it to the window we created. Add a specific script called ZPOHBPS.
Under parameter definitions, add a new parameter for BPSNUM. These will be the parameters we pass to the action directly from the source screen.
Provide a new parameter to pass the supplier number to the window

Creating the Button

To allow this window to pop up on the purchase orders screen, we need to add a button to the window.
Navigate to Development -> Script Dictionary -> Windows
A new menu line is added under address labelled Contact Details.
Search for OPOH in the left browser to find the window associated with the purchase orders screen. Under Buttons/menus, add a new button or menu item.
Add a new non-validating button linking to the ZPOHBPS action.
The button should link to the action created above. When this button is clicked, the action will be called and the window will show, running any code we write in the action specific script. We need to pass the value to the BPSNUM parameter by setting it under the parameter definition block.
Pass the screen value from the order screen to the window.

Activating the Button

By default, buttons added under the ‘menu’ type are greyed out. To activate this button, we need to go to the specific script for the purchase orders screen and register it.
Navigate to Development -> Script Dictionary -> Script Editor
Open the SPEPOH script by typing the script name under the File name field. Add the following code under the $SETBOUT action to register the new menu item.
$ACTION
Case ACTION
 When "SETBOUT" : Gosub SETBOUT
 When Default
Endcase
Return$SETBOUT
 CHMEN += "r" # Add button code to CHMEN variable
Return
Compile the script, then validate the entry transaction under Parameters -> Purchasing -> Orders. You should now be able to click on the button and see a pop-up window appear with the fields from the screen.
The new window will display with blank fields.

Populating the Fields

All that is left to do is populate the new fields on the window. This is easily done by writing a snippet of code in the action created earlier.
Navigate to Development -> Script Dictionary -> Script Editor
Open the ZPOHBPS script by typing the script name under the File name field. Add the following code to the $DEBUT action. This will read from the tables, write the values to the screen fields created earlier and refresh the fields to populate the data.
$ACTION
Case ACTION
  When "DEBUT" : Gosub DEBUT
  When Default
Endcase
Return

$DEBUT

  # Read from the tables to fetch data
  If !clalev([F:BPS]) : Local File BPSUPPLIER [BPS] : Endif
  Read [BPS]BPS0 = PARAM(1)

  If !clalev([F:BPA]) : Local File BPADDRESS [BPA] : Endif
  Read [BPA]BPA0 = 1;PARAM(1);"AD1"
  
  # Write to screen fields
  [M:ZPOHBPS]BPSNUM = [BPS]BPSNUM
  [M:ZPOHBPS]BPSNAM = [BPS]BPSNAM
  [M:ZPOHBPS]TELNUM = [BPA]TEL(0)
  [M:ZPOHBPS]MOBNUM = [BPA]TEL(4)
  [M:ZPOHBPS]EMAIL  = [BPA]WEB(0)
  [M:ZPOHBPS]ADDLIG(0) = [BPA]BPAADDLIG(0)
  [M:ZPOHBPS]ADDLIG(1) = [BPA]BPAADDLIG(1)
  [M:ZPOHBPS]ADDLIG(2) = [BPA]BPAADDLIG(2)
  [M:ZPOHBPS]CTY = [BPA]CTY
  [M:ZPOHBPS]POSCOD = [BPA]POSCOD
  
  # Refresh screen fields
  Affzo [M:ZPOHBPS]
Return
The final view should look something like this…

Entradas populares de este blog

Valores de fstat

Fstat fstat  is a numeric status that is returned upon execution of a database operation, a sequential file operation, or a lock instruction. Syntax fstat Examples # MYTABLE is a table with a key called KEY1, that has a unique component called KEYVAL # Create a record in the table MYTABLE with they key value 1 if it doesn't exist Local File MYTABLE [MYT] Read [MYT]KEY1=1 If fstat [MYT]KEYVAL=1 : Write [MYT] If fstat MSG="The key was created in the mean time" Else MSG="Key created" Endif Else MSG="Key already exists" Endif Details fstat  is always set to '0' if the operation is successfully completed, and has a non-null value if there is an error: In a sequential read ( Getseq  and  Rdseq ),  fstat  is set to '1' at the end of the file. On  Lock ,  fstat  is set to '1' if the lock could not be performed. For a database operation ( Read ,  Look ,  Readlock ,  For ,  Write ,  ...

How to create an additional line text (ACLOB) on purchase orders for internal notes

Sin conexión Kyle Klinger hace 1 día Origen:  https://www.sagecity.com/support_communities/sage_erp_x3/f/sage-x3-general-discussion-forum/143870/how-to-create-an-additional-line-text-aclob-on-purchase-orders-for-internal-notes I was trying to add internal notes to the purchase orders at a line level and was thought I would share a how to.  If you have a better way, please share.     Add column to PORDERQ; YLINTEX2, Type TXC   Save and validate table This is where the ID of the text will be stored at the record level, i.e. POQ~00000007, this is similar to field LINTEX  On screen POH2 Add column YLINTEX2, to Block 1. Most likely you will want this field to be hidden. On column NBLIG add a button action ACLOB2, description "Text internal" This button action will require an action parameter "CODE2", it will not be available until after save. Set the parameter "CODE2" to [M:POH2]YLINTEX2(nolign-2), the field that was just added....

3 ways to send a mail from code in Sage X3, with more attachments too

Origen Fuente:  https://en.sagedev.it/sagex3/send-mail-from-code-with-attachments-sage-x3/ Autor:  https://en.sagedev.it/category/sagex3/ In this post I’ll show you how to send a mail from adonix code in Sage X3. The points we will face are: 1) Meladx/Send introduction 2) Sending  through  meladx (the best way for me: at the end with just a single code line you send a mail!) 3) Sending  through  Workflow 4) Sending  through  ENVOI_MAIL(…) From AWRKMEL Sending mail from code in Sage X3: Send vs meladx Sage X3 has two native ways for sending mails. The first way is  meladx  executable file, that you can find in  runtime\bin  directory. The seconde one is Send instruction, that was used to send mail through an application of the client station (for more information on “Send GSERMES”  go here ). The Meladx executable Meladx send messages through SMTP/POP3 protocols by means of the mail  ...