eric72 wrote:
> "Chris Brown" wrote in message
>
>> eric72 wrote:
>>> Hi,
>>>
>>> I'd like to create a DB. This DB contains some records : Book_1,
>>> Book_2...., Book_x
>>>
>>> In Book_1, there is a PORTAL which contains
>>> at the left : Chap_1
>>> Chap_2
>>> Chap_3
>>> Chap_4
>>> ...
>>> and at the right : Field_A
>>>
>>> Field_B (not the same line)
>>>
>>> If I click on Chap_1, this displays some information in Field_A &
>>> Field_B
>>> the same, click on Chap_2, this displays some information in
>>> Field_A & Field_B (of Chap_2)
>>>
>>> My question : Is it possible that the PORTAL and Field_A & Field_B
>>> in the same LAYOUT ? (and there should be a script
>>> to create
>>> the chap_x because "new record" is used to create
>>> new book_y)
>>>
>>> If yes, how can do that, your help will be highly appreciated.
>>>
>>> Thank you in advanced
>> I am assuming you are on a Book table layout, and the portal just
>> displays chapters related to the current book record.
>>
>> script on the portal row parses the Chapt_ID to a global g_ChaptID
>> create a multi-parameter relationship Book_ID::Book_ID and the global to
>> Chapt_ID
>> add the Field_A and Field_B fields to the layout, using the new rel
>>
>>
>> To create a new chapter for the current book record, depends on what FM
>> version you are using.
>>
>> If FM9;
>> parse BookID to variable $_BID
>> go chapter layout
>> new record
>> hard code $_BID to Chapter::Book_ID
>> calculate and hard code the chapter number (several ways to do this)
>> return to Book layout
>> commit/refresh
>>
>>
>> or use an acrr (allow creation related record) rel
>> calculate and enter the new chapter number into a global
>> create an acrr rel BookID and ChapterNo from Book to Chapter table
>> set field A = ""
>> and variations on this
>>
>>
>> The chapter no could be calculated from the count of related chapters + 1
>
> ---------------------------------------------------------------------------------
>
> Hello Chris,
>
> You are right, I'm on a Book table layout, and the portal just
> displays chapters related to the current book record.
>
> I create two tables: (and two layouts Book & Chapter)
>
> Table_Book : Book_ID ; Field_A ; Field_B ; global_ChaptID
>
> Table_Chapter : Book_ID2 ; Chapter_ID ;
>
> and two relationships:
>
> Relationship 1 : Book_ID = Book_ID2
>
> Relationship 2 : global_ChaptID = Chapter_ID
>
>
> and I don't know where Field_A and Field_B connect to ?
>
>
> (I use FM 9 advanced)
>
> For the script, I don't understand your words "Parse" and "hard"
>
> Set Field [ Table_Book::global_ChaptID ; Table_Chapter::Chapter_ID]
>
> Go to Layout [Chapter]
>
> New Record/Request
>
> ...
>
> ...
>
> Go to Layout [Book]
>
> Commit Records/Requests []
>
> Refresh Window
>
>
>
> Can you help me to complete the script because it is not
> clear for me and it's a little difficult to understand
> your idea.
>
> Thank you very much
>
>
>
Hi Eric
Parse: extract the value required, from the source data
Hard code: record the value/data in a 'non'volatile' field (i.e. text,
number ...) field, as distinct to holding the value temporarily in a
variable or global. The value is going to be used, in this instance, as
a foreign key, so has to be recorded permanently.
<<
> Table_Book : Book_ID ; Field_A ; Field_B ; global_ChaptID
>
> Table_Chapter : Book_ID2 ; Chapter_ID ;
>
If FieldA and FieldB are the chapter content (I am assuming), then they
should be in the Chapter table, and not the Book table(as you last
indicated)
So you are on the Book layout
The portal on Book layout displays the related Chapters for that Book
Record, using Rel_1 (Book_BID::Chapter_BID)
The select/display BookChapter script is placed on the portal row. The
script grabs/parses the portal row ChaptID, and records that value in a
global g-ChapID; this becomes a key to establish rel2
The FieldA FieldB chapter content/details RELATED fields are placed on
the Book layout, external to the portal. These fields use Rel_2 which
must be a multi-paramater rel using both BookID and g_ChapterID
Book_BookID::Chap_BookID
Book_g_ChapID::Chap_ChapID
The Rel_2 must be both BookID and ChaptID or else the related chaptID
displayed will be the FIRST chapter record found by a single parameter
(ChaptID) rel (depending on the sort) i.e it will be the same chapt
record for every book record. A bit difficult to explain, but will be
obvious when you step through book records and the same Chapt 2 details
are displayed on every Book record for example.
The create a new Chapter script, could either
1 use a 3rd rel (acrr), or
2. grab the origin BookID
calculate the count of chapters for the book, and so the new chapt
number = count +1 ; temporarily hold in variable $_Chapt
go to Chapt layout, create a new Chapt record
record/stamp/hard code the origin bookID to the new Chapt recor
hard code/record/stamp the new Chapt number (initailly calculatated from
the count of chapters for the origin book
return to the book layout
refresh the window
commit the record
(the last 2 steps are not actually necessary in this instance, as
changing layouts will achieve the same result, however I included this
as they are a worthwhile/safe last steps in all scripts; That way you
don't get caught out when they are required.
regards
Chris
>> Stay informed about: Portal Navigation