www.Inmagic.com    Inmagic Forums    Inmagic Forums  Hop To Forum Categories  Scripting    Forcing specifc edit form
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Posted
I have a textbase which contains two slightly different types of records. I've designed two versions of the edit form -- one for each type. The two types of record can be distinguished by the entry in a specific field -- it's either "article" or "book."

I'd like to fix it so that the appropriate edit form pops up when a user clicks on the Edit Record button (or selects the edit option from the dropdown menu) on either the Record display form or the Report Form.

I'm envisioning a script that checks the content of the field which identifies the item type and brings up the Book Edit form if the field content = "Book" and the Article Edit form if the field content = "article."

Is this possible? I know I can create script buttons to do it, but I'd like those menu buttons to behave right also.
 
Posts: 10 | Location: San Mateo, CA, USA | Registered: Thu April 24 2003Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
You cannot currently change the behavior of the normal toolbar button and menu choice.

If you email wishlist@inmagic.com your contact information (name & company), I can enter a feature request for you.

[This message has been edited by Lisa (edited 25 April 2003).]
 
Posts: 1890 | Location: Woburn, MA, USA | Registered: Thu July 13 2000Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
Er, this is totally do-able, and here's an example. I scripted this for a textbase that had different values in a RecordType field, and I wanted the appropriate edit screen to be used with each record type. There were 4 entry forms, and three of them were specific to a record type value. The fourth acted as sort of a generic or general entry form for the other record type values. It works perfectly - whenever a user opens a record in an edit environment, doesn't matter where from, the record type value is checked, and the edit form switched as necessary.

EXAMPLE

Let's say there are two entry forms: Entry-Book and Entry-Article. For our purposes there are three possibilities for the RecordType value: Book, Article, and neither of those two (blank value "" or unrecognized value like Journal, Website, etc.). In the example below, if the record being opened contains "Article" in the RecordType field, then the form will switch to Entry-Article. If RecordType is blank (i.e. this is a new record or field is blank for some other reason) nothing will happen - you can modify this. If RecordType is unrecognizable (that just means unanticipated) then nothing will happen - you can modify this too. My real-life version switched to the generic entry form when either of these situations was encountered.

Here's the script for Entry-Book:

// Entry-Book script
// Assign the RecordType box the name boxRecordType

function onRecordOpen()
{
// if RecordType value isn't "Book", take action
if (Form.boxes("boxRecordType").content != "Book") {

// if RecordType value is "Article", switch to Entry-Article form
if (Form.boxes("boxRecordType").content == "Article") {
Command.selectFormsEx("","Entry-Article","","");
}

else if (Form.boxes("boxRecordType").content == "") {
// could go somewhere else if RecordType was blank
// as it is, nothing will happen
}

else {
// could go somewhere else if RecordType is unrecognizable
// as it is, nothing will happen
}

} // end if

} // end fxn


The script for Entry-Article will be similar except that of course you'd replace instances of "Book" with "Article" and vice versa, as well as "Entry-Article" with "Entry-Book".

The above script can accommodate other forms for specific RecordType values as well, you just have to add them into the template I've provided as separate if statements.

Good luck.


Peter Tyrrell
Senior Consultant
Andornot Consulting Inc. http://www.andornot.com
 
Posts: 179 | Location: Vancouver, BC, Canada | Registered: Thu September 20 2001Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
You will have to already have one of the forms with the scripts as your default edit form in order for this to work.
 
Posts: 1890 | Location: Woburn, MA, USA | Registered: Thu July 13 2000Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
That's right. Every existing entry form should have some script that will switch forms if necessary. Also the textbase form defaults and any menu links that open the textbase should be checked to make sure the basic edit form is not being used, as there can be no script added to that.
 
Posts: 179 | Location: Vancouver, BC, Canada | Registered: Thu September 20 2001Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
Peter, thanks so much for the information and the example. I'm just getting back to this after months of letting it sit, so I'm going to set about trying it out for myself. I'll let you know how it goes.


--- Holy cow, it works like a charm! Thank you, thank you, thank you.

[This message has been edited by NancyF (edited 05 June 2003).]
 
Posts: 10 | Location: San Mateo, CA, USA | Registered: Thu April 24 2003Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
On a similar vein.....I have a linked database (serials db links to catalogue db). In my serials database,I have a button which will go to the catalogue record in the default edit form. Is it possible to specify an edit form which it should go to rather than going to the default edit form?

Right now the form uses the script

function btnGoCatalogue_onClick()
{
Form.boxes("boxCatalogLink").setFocus()
Command.editSecondaryRecord()
}

Is there a way I can specify which Edit form it should go to?

Thanks.


Shona Lam, Librarian
BC Cancer Agency
Vancouver Cancer Centre
600 West 10th Ave, Vancouver BC, Canada V5Z 4E6
stlam@bccancer.bc.ca
ph: 604-877-6000x-2692
fax: 604-877-6095
 
Posts: 12 | Location: Vancouver, BC Canada | Registered: Wed November 13 2002Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
OK, disregard my last message of April 2004. What I've ended up doing is using Peter's script so that if the Format is Serial it opens to the edit form for a Serial (rather than the default edit form which is a book). This works very nicely, and solved a problem that I had with my linked Serials/Catalogue database.

Is there a way though....to sometimes bypass the script. There may be times when we do want the full default edit form, rather than the Serial form. ie Could I have a script button which will change to the full edit form if I want? I tried adding:

function btnChangeDisplay_onClick()
{
Command.selectWindowForm()
}

But of course that won't work because when the record opens, it sees the Format=Serial and then goes to the other form. ALSO, the problem with this Change Display script is that it totally changes all the Select Form defaults and makes other things wonky unless you get out of the system.

Shona


Shona Lam, Librarian
BC Cancer Agency
Vancouver Cancer Centre
600 West 10th Ave, Vancouver BC, Canada V5Z 4E6
stlam@bccancer.bc.ca
ph: 604-877-6000x-2692
fax: 604-877-6095
 
Posts: 12 | Location: Vancouver, BC Canada | Registered: Wed November 13 2002Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
This is something of a challenge because form script is annihilated when the form changes, so that script decisions made in Form A cannot be carried over to Form B except by session variables. Session variables hold information across form changes, and you need to set a flag at the session level that would be checked in the script that automatically changed forms.

Set session flag to false when Form A loads.

Application.sessionStore.value("formFlag") = false;

Set session flag to true if btnChangeDisplay is clicked.

Application.sessionStore.value("formFlag") = true;

When FormB loads, only auto-switch forms by script if flag is false.

if (Application.sessionStore.value("formFlag") == false) ...

If flag is true when FormB loads, do not switch forms but do immediately set flag to false again.

Application.sessionStore.value("formFlag") = false;


A session store object lasts only as long as the textbase is open.

Peter


Peter Tyrrell, MLIS
Senior Consultant
Andornot Consulting Inc.
http://www.andornot.com/about/developerblog
 
Posts: 179 | Location: Vancouver, BC, Canada | Registered: Thu September 20 2001Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
Thanks Peter, I understand the concept, but I'm missing something.

1) Does a session flag have a default value of true or false if it has not been given a value in any previous statement. Or must a session flag be defined with a value.

2) Can a session flag be given a value other than true or false?

3) I think I'm mixing up what form a and form b are and I've tried it both ways, but neither seem to work. I think my problem is that form A (partial edit form) only loads because of what is stated in form b (the complete edit form).

ie the default edit form is form b (complete edit form)
- if format=serial then it is supposed to go to form a (serial edit form)
-BUT if someone wants to changed the edit form to form b (complete edit form), I'd like for them to be able to click a button and go to form b

The problem is the inital time when the default edit form is open (form b) there is no value to the session flag. If I assign it a value, then it would over-ride what was assigned when in form a.

Thanks.

Shona


Shona Lam, Librarian
BC Cancer Agency
Vancouver Cancer Centre
600 West 10th Ave, Vancouver BC, Canada V5Z 4E6
stlam@bccancer.bc.ca
ph: 604-877-6000x-2692
fax: 604-877-6095
 
Posts: 12 | Location: Vancouver, BC Canada | Registered: Wed November 13 2002Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
Hi,

I've been trying for a long time what Peter explains: fix the appropiate edit form for every different type of record.

Now, I've find the solution here, but I'm just getting my feet wet with scripting, and I'm not sure where I've to write it in?! I've used scripting to design help buttons, and going to secondary records, move entries,... and it's worked, but I'm so confused about this new script.

Could anyone help me?

Thank you very much in advance,

B.
 
Posts: 10 | Location: Barcelona, Spain | Registered: Tue October 03 2006Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

www.Inmagic.com    Inmagic Forums    Inmagic Forums  Hop To Forum Categories  Scripting    Forcing specifc edit form