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!
|
|
Set Mainview Name at runtime
Posted: 03 Jun 08 4:48 PM
|
I have a script that is setting a managed form as a mainview. When I try setting the mainview name with the script and capture it in a message box the application.mainviews.activeview.name is blank. This is the script that calls the form and sets it as the mainview:
Sub Main Dim objMv Dim id
Application.BasicFunctions.DoInvoke "Form", "Training:TR_ClassesBreakouts" Application.GlobalInfo("fxCurrentQuoteID") = "Test" id = Application.GlobalInfo("fxCurrentQuoteID") If (Trim(id) <> "") Then Set objMv = Application.MainViews.Add("Training:TR_ClassesBreakouts", 1, True) With objMv .Caption = "PCS Training" .Refresh .Show .Name = "Training:TR_ClassesBreakouts" End With End If
Application.GlobalInfo.Delete("fxCurrentQuoteID") End Sub
Any suggestions on getting the .Name set??
Thanks........
|
|
|
|
Re: Set Mainview Name at runtime
Posted: 03 Jun 08 5:48 PM
|
So you're invoking application.mainviews.activeview.name at some point later down the line?
Have you tried running in debug to work out where the property disappears - and to confirm that it does get set correctly?
Phil |
|
|
|
Re: Set Mainview Name at runtime
Posted: 04 Jun 08 8:07 AM
|
Yes, I tried invoking application.mainviews.activeview.name = "some name" and it is not getting set. I moved this to different locations to see if it made a difference when I tried setting it but I always ended up with nothing in the message box I would display. |
|
|
|
Re: Set Mainview Name at runtime
Posted: 04 Jun 08 9:14 AM
|
One thing that stood out to me is the DoInvoke call which creates the form and displays it. Then immediately after that you use the MainView load technique to display it again?
It seems to make more sense to just use the MainView loading technique, get your globalinfo then do your processing. DoInvoke I believe waits for a return before proceeding to the next line of code so what you're doing is a little awkward to me.
Having said all of this, have you looked in any of the SalesLogix stock mainview code? Do a system-wide search for MainViews.Add then go through each script seeing if they change the name. I wouldn't think this was possible to do because the Forms collection keeps a reference by name and you're already modifying the Caption to begin with. I guess I'm wondering why you need to change this when it's basically (in my mind) saying "Change the form I named/saved in Architect C_Form to C_Form2" when you can't really do that at runtime. It's probably a limitation of the system if I had to guess.
Searching the stock code should give you a little better understanding of what's happening and the things you are allowed to change at runtime. Some of the stock code does some pretty deep manipulation so I'm guessing that if you don't find it then it's not possible to change. |
|
|
|
Re: Set Mainview Name at runtime
Posted: 04 Jun 08 10:14 AM
|
This was some code that our business partner sent me, so I am trying to modify it to suit my needs. I was trying to set the name because it doesn't appear to be setting it when I added msgbox application.mainviews.activeview.name it returned an empty message box. |
|
|
|
Re: Set Mainview Name at runtime
Posted: 04 Jun 08 5:10 PM
|
Hi Bill,
So what is the intent of this? What are you trying to accomplish? Some background would help. As Jeremy stated, there's a mixing of some things in here somewhere, loading the same form twice, once using DoInvoke and then again as a MainView.
Can you explain what you're trying to have happen and we can get you on the right track.
-Ryan |
|
|
|
Re: Set Mainview Name at runtime
Posted: 04 Jun 08 7:53 PM
|
This code was sent to me by our business parntner and I am using it to open a form as a main view. I modified the code by removing the DoInvoke so it is only loading the form once. I was trying so get the mainview.name set so the script will only fire if the form isn't open. Without any verification I can click the button endlessly and it will open a new form for every button click. I was able to get the mainview.caption set so I can use that. I also set a global variable with a count value of 1, that way if a user navigates to the Account or Contact view while this form is open the script won't fire to open a new form when they want to navigate back to it. I check the global count variable and if it is equal to 1 I just call the open form to the front. I didn't get a chance to get all of the scripting in place for that yet, but that is my current plan. It sounds like it should work when discussing it with another developer I work with but there are times when the easiest ideas are the most difficult to execute.
Thanks for all the help guys!!!!!!! |
|
|
|
Re: Set Mainview Name at runtime
Posted: 04 Jun 08 8:27 PM
|
1) Are you loading a form as a MainView object or is it a MainView plugin? Meaning, are you wanting to open it as a floating window or a MainView like the account/contact/etc areas that fill the entire client?
2) What is your purpose in setting the "Name" property of the MainView? I don't believe that is a settable property. It is a read-only property that returns the name of the plugin itself. What the goal there?
3) The 3rd param for MainViews.Add is a boolean that is meant to indicate whether to reuse an already open/existing MainView or not. You do have that set to True, however, IIRC this only applies to MainView plugins, not forms loaded as MainView objects.
I'm not sure I have the whole scenario, so if you could describe what you want the end result to be with some addl details that would be helpful.
Thanks. |
|
|
|
Re: Set Mainview Name at runtime
Posted: 05 Jun 08 8:21 AM
|
1) I am loading it as a main view like the Account/Contact screens.
2) I was going to set the name so I could use that for an "If" statement - meaning if the mainview name was equal to the name of this mainview I wouldn't allow another instance of this mainview to open if the user navigated to the Account or Contact views and then clicked the nav button to be returned to this mainview. If the user navigates to an Account or Contact view and this mainview is open I will then bring it back to the front as the active mainview.
What I am attemting to do is get this form that is being loaded as a mainview to have the same look, feel, and actions as the Account/Contact mainviews. It is working fine, but if a user clicks the Nav button I added it will open a new instance of the mainview for every click. I was able to get that resolved but I need to be able to get this screen back to the front as the active mainview if the user goes to an Account/Contact mainview. |
|
|
|
Re: Set Mainview Name at runtime
Posted: 05 Jun 08 11:07 AM
|
Maybe you could take a look at the code in Global Scripts:Global Reports - this has an example of getting a single instance of a main view |
|
|
|