Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Monday, July 7, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Architect Forums - SalesLogix Scripting & Customization
Forum to discuss writing script in Architect plugins for SalesLogix & general SalesLogix customization topics (for Windows client only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Scripting & Customization | New ThreadView:  Search:  
 Author  Thread: Form.Post method does not work with form Application.Mainviews.Add
Chris Fleetwood
Posts: 35
 
Form.Post method does not work with form Application.Mainviews.AddYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jul 10 11:46 AM
Hey All,

I am using a bound data form with an OK button that invokes the Form.Post method. I am currently using ShowViewForRecord to display the form to either create a new record or update an existing one:

application.BasicFunctions.ShowViewForRecord "gk_onsitereq_idr","Eventix:Create Initial Date Request (IDR)", txtIDR.Text

This works fine, however the form in question is a very long form with a lot of data being displayed (I am already using tab views and even wrote script to move controls around in specific scenarios to try to maximize display area) and we have a number of users with low-resolution laptops who cannot see part of the form.

I decided to make the form resizable by user, but I know the form modal properties are "permanent" once the form is invoked. On the posted suggestion of another user, I am trying out Application.Mainviews.Add to display the form, which does allow me to specify the bordertype ("2") and, as a result, the invoked form is now resizable and scrollable:

Set objView = Application.MainViews.Add("Eventix:Create Initial Date Request (IDR)", 0, False)
objView.BorderStyle = 2
Set objDetail = objView.DetailsView
objDetail.txtEntOppID.Text = txtOppID.Text
objDetail.txtSalesOppID.Text = CurrentID
objDetail.Script.AXFormChange frmSalesOpportunity
If objView.ShowModal = mrOK Then
End If
Set objView = Nothing
Set objDetail = Nothing

However, with this change I have created another problem. The Post method no longer works with the data form. I have been reading a couple of other posts which appear to suggest that any "insert" or "update" from a form called this way would have to explicitly scripted as the form would have to be "unbound".

Is this the case? I don't want to completely redesign the "called form".

It would be less trouble to return to using ShowViewForRecord to display the form and rearrange the controls on the form, which is definitely not a desirable alternative. Am I missing something here? Any insights would, of course, be greatly appreciated.

Chris
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Form.Post method does not work with form Application.Mainviews.AddYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jul 10 12:57 PM
think of the MainView object as a Data Form shell.

your Data Form (NOT a managed form) (the one with the CurrentID, OK button set to mrOK, and the form events (AXFormChange, AXFormOpen, etc.) handlers) is housed In that MainViewObject.

Set objView = Application.MainViews.Add("Eventix:Create Initial Date Request (IDR)", 0, False)
objView.BorderStyle = 2
Set objDetail = objView.DetailsView

Run an INIT routine on your Data Form!
pass the data form the values that it needs...the INIT form sets all local controls.

This (believe it or NOT!) means show the form!

If objView.ShowModal

Yes I know it's also the return, but that's when the form is displayed for the user AND returned.

ON the Data Form:
Many form events DO NOT FIRE.
Especially if you don't have any databound controls.

AXFormOpen can be used to set some controls, but you probably should do this from the INIT routine.

AXFormChange DOES NOT FIRE if there are no databound controls.

AXFormValidate probably will NEVER fire unless you have a databound control and the user touches it (makes it 'dirty').

The MODAL RESULT is set by the OK Button. IF you want to fire some commit changes to the database stuff, now is the time to do it....

the modal result also closes the window automagically.

Why do you need a form.post? to store intermediate results? If this is a new record, what is there to Post to (what is the landing spot for the post)?

I don't know if a Form.Post actually works in a MainView object....if the data form works correctly (on a ShowViewForRecord or Data Grid pop) then simply clicking on the OK button is enough for SLX to store\insert that table's databound control.....

A data form deals with one table of changes per form.....other tables either need scripting or a datagrid to store other tables\fields of data.

Prove to yourself that the Data Form can be launched and records inserted\updated....then add your controls to it......

reprove it....

then launch it as a mainview, use an INIT proc to set form values...

Sub LaunchAddEditProductView ( Mode )
Dim objMainView
Dim objDetail
Dim strPrdID

Set objMainView = Application.MainViews.Add(ProductDFName, 0, False)
objMainView.BorderStyle = 2
Set objDetail = objMainView.DetailsView

If Mode = "Edit" Then 'DNL
objMainView.Caption = Application.Translator.Localize("Edit Product")
Else
CurrentProductID= ""
objMainView.Caption = Application.Translator.Localize("Add Product")
End If

objDetail.Script.Init Mode, CurrentProductID

If objMainView.ShowModal = mrOK Then

End If

Set objDetail = Nothing
Set objMainView = Nothing
End Sub


When the user clicks on the Data Form's OK button, the data is saved or updated. No form.post is used in the Data Form.

Here's the init subroutine on the Data Form:


Sub INIT (Mode, ProductID )
' initialize variables and form controls.
CurrentUserID = Trim(application.BasicFunctions.CurrentUserID)
TheProductMode = Mode
If ProductID = "" Then 'Adding a product
ProductID = "ADD" & Right(cSTR(Timer),9) ' temporary ID instead of a permanent one: ProductID = Application.BasicFunctions.GetIDFor("PRODUCT")
txtProductID.Text = "New Product"
txtSKU.Text = "New Product " & Timer ' Product.ActualID field must be unique.
End If

CurrentProductID = ProductID
' Application.Debug.WriteLine "INIT rtne Mode: " & TheProductMode & " ProductID: " & CurrentProductID

Call LoadProductForm ( CurrentProductID ) ' go get the Product Data, load the grids, etc.
Call HideUnhideControls
End Sub


Take a look at the Manage Product and Add Edit Product form subsystem.....
[Reply][Quote]
Chris Fleetwood
Posts: 35
 
Re: Form.Post method does not work with form Application.Mainviews.AddYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jul 10 3:17 PM
RJ -

Thanks for the info....

To clarify: The form in question is databound. I was calling it using ShowViewForRecord and in that configuration, the Form.Post was working as expected. I am using an "Add"/"Edit" condition on the form's OnCloseQuery event because the form is being processed in two (2) phases for a "new" record. The table that the form is bound to has a number of child tables and I have the form first processing the "parent record" and then when the parent is saved (the parent key is established), the form is kept "open" on the OnCloseQuery condition so that the user may enter the "child" information (that, of course, is linked to the parent key/record). However, I still wanted the parent information to write to the database on the 1st "pass", so I'm using the Form.Post method (on the OK button click event) to do so. After the second "pass" (and Form.Post) for the "child information", the OnCloseQuery condition allows the form to close. The Form.ModalResult is set to mrOK.

This configuration worked with ShowViewForRecord but is not working with Application.MainViews.Add. I actually am using AXFormChange to do the "INIT" so the form data is displaying correctly as it did before. The only difference is that the Post method is not working (again, on the OK button click event), and apparently the Form.ModalResult (mrOK) has no effect either.

Chris
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Form.Post method does not work with form Application.Mainviews.AddYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jul 10 3:54 PM
Duplicate post.
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Form.Post method does not work with form Application.Mainviews.AddYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 20 Jul 10 3:55 PM
Got it.....

I'm doing this all in the OK button.....one parent record (Product), 3 child tables (all related to Product).

NOTHING is saved until the user hits the OK button....

In your scenario, what happens if they click on Cancel after the new Parent record has been saved?

I would think that some of this stuff is simply NOT being called.....put an Application.DEBUG.Writeline "Name of Procedure BEGIN" and END at the start and ending of each of these major routines (All buttons, all form events). Make sure the stuff is being fired.....and WHEN.

When you save the Parent Record in the AXFormcloseQuery, are you filling in Form.CurrentID? Is the AXFormClose Query firing off twice (once for each 'pass'?), nullifying the Form.Post?

I think you have two many moving parts on one form (I've never used nor heard of the 'pass' concept before as SLX does all of the Insert Stuff for you when you click on OK). What happens if you ALWAYS do Pass 1 prior to calling the form? Save a basic record, launch the form, with minimal fields required filled in, let the User go after pass 2.
[Reply][Quote]
Chris Fleetwood
Posts: 35
 
Re: Form.Post method does not work with form Application.Mainviews.AddYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jul 10 9:12 AM
The reason I used the multiple passes was to have the "new" parent key before processing the "child information. This was my way of thinking when originally designing the form. The coding methodology you're talking about does make sense, though.

For my configuration, the "child" information was not required so I'm allowing the user to enter just the "main" information if they choose. The cmdOK button has a caption of "Save" on the 1st pass and "OK" on the second pass and behaves accordingly through script behind the cmdOK button. Because I'm using the AXFormCloseQuery to keep the form open after the 1st pass, I have the Form.Post method specifically called on each pass behind the cmdOK button. The cmdCancel button is available on both passes as well.

The first "pass" gets all of the required fields for the parent (main) record, the second "pass" adds child information that is not essential for the parent record. If the user cancels after the first pass, all that means is that the main record has been saved, which is OK.

I've used the STOP command to debug as well. The events themselves appear to be firing. It's just that the Form.Post method call itself (on either pass) appears to have no effect.

The AXFormCLoseQuery is set to FALSE on the 1st pass, and to TRUE on the 2nd pass.
[Reply][Quote]
RJ Samp
Posts: 973
Top 10 forum poster: 973 posts
 
Re: Form.Post method does not work with form Application.Mainviews.AddYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 21 Jul 10 12:39 PM
OK so Form.Post doesn't work with Application.Mainviews.Add

A data form is set to save data changes when the OK button is clicked and the form is closed.

The easiest way to do this is to Create the parent record first (your first pass), then open up the main view with your new record in edit mode, or your older record in edit mode.
Upon return from the form you can check on mrCancel, no child records created, etc. and delete your first pass parent record if desired.

The OK button will save changes to databound fields on the parent record only unless you script otherwise. The grids' data will save its own changes, and Cancel will not cancel this.

[Reply][Quote]
Chris Fleetwood
Posts: 35
 
Re: Form.Post method does not work with form Application.Mainviews.AddYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 26 Jul 10 10:43 AM
OK, here's the situation.

My current form configuration works perfectly ("2-pass" POSTing and all) when using ShowViewForRecord to invoke the form, but because I'm using the Application.MainViews.Add, that configuration no longer works.

My only reason to use Application.MainViews.Add in the first place is to make the form resizable/scrollable. In order for this to work, it becomes necessary to re-engineer much of the current form. If only ShowViewForRecord allowed the user to set form properties...smh

Given the fact that I'd be doing all of this just to make the form resizable, I'm thinking about an alternate approach, like just rearranging the data controls on the form. Unless there is (possibly) any other way to accomplish the form properties change(???)
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 7/7/2025 10:30:41 AM