Sorry for the long piece of code but i would really appreciate if you
(or anyone else) can check if i really understand and did it right. Is
it true that in this situation of edit the ticket and insert an answer
in one save, you really only need this kind of 'validation' for just
the answer insert object, or do you always check each object anyway?
Also i am thinking that the second cfset (in this construction):
<cfset ticketanswerssaved = lSavedObjectIDs>) of lSavedObjectIDs could
be overwritten by the first generated lSavedObjectIDs. So that would
mean the second object would always be 'validated' because of a
existing value from the first object (if generated).
For now i used:
<ft:processForm action="Save">
<ft:processFormObjects typename="tickets" bSessionOnly="true" />
<cfset ticketssaved = lSavedObjectIDs>
<cfif len(ticketssaved)>
<cfset formprefixtickets = replace(ticketssaved,'-','','ALL') />
<cfset obj = createObject
('component',application.stcoapi.tickets.typePath) />
<cfset stprops = {} />
<cfset stprops.objectid = stobj.objectid />
<cfset stprops.department = form[formprefixtickets & 'department'] />
<cfset stprops.description = form[formprefixtickets & 'description'] /
>
<cfset stprops.errorurl = form[formprefixtickets & 'errorurl'] />
<cfset stprops.notification = form[formprefixtickets &
'notification'] />
<cfset stprops.priority = form[formprefixtickets & 'priority'] />
<cfset stprops.status = form[formprefixtickets & 'status'] />
<cfset stprops.subject = form[formprefixtickets & 'subject'] />
<cfset obj.setData(stProperties=stprops) />
</cfif>
<ft:processformobjects typename="ticketanswers" bSessionOnly="true" />
<cfset ticketanswerssaved = lSavedObjectIDs>
<cfif len(ticketanswerssaved)>
<cfset formprefixticketanswers = replace
(ticketanswerssaved,'-','','ALL') />
<cfif len(form[formprefixticketanswers & 'answer'])>
<cfset obj = createObject
('component',application.stcoapi.ticketanswers.typePath) />
<cfset stprops = {} />
<cfset stprops.objectid = ticketanswerssaved />
<cfset stprops.ticketobjectid = stobj.objectid />
<cfset stprops.answer = form[formprefixticketanswers & 'answer'] />
<cfset obj.setData(stProperties=stprops) />
</cfif>
</cfif>
</ft:processForm>
Thanks
On Dec 2, 1:34 am, "Blair McKenzie" <[EMAIL PROTECTED]> wrote:
> lSavedObjectIDs gets overwritten by each ft:processformobjects. You need to
> copy it, or use it, immediately after the tag.
>
> On Tue, Dec 2, 2008 at 5:06 AM, Marco van den Oever <
>
> [EMAIL PROTECTED]> wrote:
>
> > And also, in the above code i changed:
>
> > <cfif isdefined('lSavedObjectIDs')> to <cfif len(lSavedObjectIDs)>
>
> > else when adding an new ticket the save action gives an error that the
> > answer field was not found in the form scope, as it is the first save
> > the answer form field is not yet generated on the page as it is only
> > generated when editing the ticket for the first time, so it fails to
> > read the answer form field.
>
> > And the 'lSavedObjectIDs is defined anyway but only has a value when i
> > use the answer form and the object that belongs to it.
>
> > Just to correct my example...
>
> > On Dec 1, 5:38 pm, Marco van den Oever <[EMAIL PROTECTED]>
> > wrote:
> > > No problem, i didn't know either about the lSavedObjectIDs, but it's
> > > very handy :)
> > > It basically works now and i could use a far more easier code so
> > > that's already very nice.
>
> > > Thanks
>
> > > On Dec 1, 5:29 pm, "Tomek Kott" <[EMAIL PROTECTED]> wrote:
>
> > > > sorry, i have no idea now, I didn't even know that there was such a
> > thing as
> > > > lSavedObjectIDs....
> > > > good luck,
>
> > > > Tomek
>
> > > > On Mon, Dec 1, 2008 at 11:10 AM, Marco van den Oever <
>
> > > > [EMAIL PROTECTED]> wrote:
>
> > > > > Tried that already and then:
>
> > > > > <cfdump var="#lSavedObjectIDs#">
> > > > > <cfabort>
>
> > > > > Do i need to cfdump it in a different way?
>
> > > > > But just 1 objectid, a new one, so generated for the new
> > ticketanswers
> > > > > objectid.
>
> > > > > Does it might have to do with the way i setup the ticket object,
> > > > > divided into 3 parts?:
>
> > > > > <ft:object typename="tickets" objectid="#stobj.objectid#"
> > > > > lFields="department,subject,errorurl,description" r_stPrefix="prefix"
> > > > > legend="General Details" />
>
> > > > > <ft:object typename="tickets" objectid="#stobj.objectid#"
> > > > > lFields="priority" r_stPrefix="prefix" legend="Priority" />
>
> > > > > <ft:object typename="tickets" objectid="#stobj.objectid#"
> > > > > lFields="notification" r_stPrefix="prefix" legend="Notification" />
>
> > > > > Thanks
>
> > > > > On Dec 1, 4:19 pm, "Tomek Kott" <[EMAIL PROTECTED]> wrote:
> > > > > > Hmm, what if you do bSessionOnly on both the process form objects
> > calls?
>
> > > > > > On Mon, Dec 1, 2008 at 10:17 AM, Marco van den Oever <
>
> > > > > > [EMAIL PROTECTED]> wrote:
>
> > > > > > > As the ticket already exist i thought now i only could use the
> > method
> > > > > > > like you described for the ticketanswer object.
>
> > > > > > > To be honoust, when i do a cfdump lSavedObjectIDs, i only see the
> > new
> > > > > > > generated objectid of the ticketanswers object, i don't see two
> > > > > > > objectid's (one of tickets object and one of ticketanswers
> > object). Or
> > > > > > > am i missing something?
>
> > > > > > > So how can i check for both? For now this is working, and with
> > less
> > > > > > > complicated code! but it might not do 100% of what you meant.
>
> > > > > > > I created it like:
>
> > > > > > > <ft:processForm action="Save">
>
> > > > > > > <ft:processFormObjects typename="tickets" />
>
> > > > > > > <ft:processformobjects typename="ticketanswers"
> > bSessionOnly="true" />
>
> > > > > > > <cfif isdefined('lSavedObjectIDs')>
>
> > > > > > > <cfset formprefix = replace(lSavedObjectIDs,'-','','ALL') />
>
> > > > > > > <cfif form[formprefix & 'answer'] gt 0>
>
> > > > > > > <cfset obj = createObject
> > > > > > > ('component',application.stcoapi.ticketanswers.typePath) />
> > > > > > > <cfset stprops = {} />
> > > > > > > <cfset stprops.objectid = lSavedObjectIDs />
> > > > > > > <cfset stprops.ticketobjectid = stobj.objectid />
> > > > > > > <cfset stprops.answer = form[formprefix & 'answer'] />
> > > > > > > <cfset obj.setData(stProperties=stprops) />
>
> > > > > > > </cfif>
>
> > > > > > > </cfif>
>
> > > > > > > </ft:processForm>
>
> > > > > > > And the ticketanswers object without a given objectid so a new
> > one is
> > > > > > > created as default and as prefix for the submitted form field:
>
> > > > > > > <ft:object typename="ticketanswers" lFields="answer"
> > > > > > > r_stPrefix="prefix" legend="Answer" />
>
> > > > > > > Thanks very much
>
> > > > > > > On Dec 1, 3:51 am, Marco van den Oever <
> > [EMAIL PROTECTED]>
> > > > > > > wrote:
> > > > > > > > Awesome, just wanted to know for sure, thanks!
>
> > > > > > > > On Dec 1, 3:15 am, "Blair McKenzie" <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > Use bSessionOnly to stop them from being saved to the
> > database,
> > > > > make
> > > > > > > the
> > > > > > > > > changes you need (e.g. setting a uuid property on one), then
> > use
> > > > > > > setData to
> > > > > > > > > write the objects to the database.
>
> > > > > > > > > On Mon, Dec 1, 2008 at 12:41 PM, Marco van den Oever <
>
> > > > > > > > > [EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > Good to know! Based on the fact you gave the example of
> > using
> > > > > > > > > > lSavedObjectIDs as response to the code i showed, you
> > advice me
> > > > > to
> > > > > > > > > > adjust my code to a usage with lSavedObjectIDs?
>
> > > > > > > > > > As my mind runs over it i get stuck at the point i submit
> > the
> > > > > both
> > > > > > > > > > objects at the same time , so therefore the 'after save'
> > > > > > > > > > lSavedObjectIDs can't be used, would you advice me to
> > change the
> > > > > code
> > > > > > > > > > so that it can use this method?
>
> > > > > > > > > > On Dec 1, 1:57 am, "Blair McKenzie" <[EMAIL PROTECTED]>
> > wrote:
> > > > > > > > > > > I would usually put basic save actions in one of the save
> > > > > functions
> > > > > > > -
> > > > > > > > > > > beforeSave, setData, or afterSave, depending on what I
> > want to
> > > > > do.
>
> > > > > > > > > > > I use lSavedObjectIDs mainly for when I need to create
> > > > > secondary
> > > > > > > objects
> > > > > > > > > > > that are dependant on another.
>
> > > > > > > > > > > Another situation that can come up is when you are
> > creating two
> > > > > > > that are
> > > > > > > > > > > co-dependant - for example if both objects should fail if
> > > > > either
> > > > > > > one has
> > > > > > > > > > an
> > > > > > > > > > > error, or if they both have references to each other. In
> > that
> > > > > case
> > > > > > > I put
> > > > > > > > > > > bSessionOnly="true" (saves the object just for the
> > session) on
> > > > > > > > > > > ft:processformobjects and retrieve the new object with
> > > > > > > lSavedObjectIDs.
> > > > > > > > > > Then
> > > > > > > > > > > at the end of the ft:processformobjects if there are no
> > > > > problems,
> > > > > > > use
> > > > > > > > > > > setData to resave the objects to the database.
>
> > > > > > > > > > > On Mon, Dec 1, 2008 at 11:47 AM, Marco van den Oever <
>
> > > > > > > > > > > [EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > > > That is interesting, so you could use that for after
> > save
> > > > > actions
> > > > > > > > > > > > mostly?
>
> > > > > > > > > > > > On Dec 1, 1:31 am, "Blair McKenzie" <[EMAIL PROTECTED]>
> > > > > wrote:
> > > > > > > > > > > > > When ft:processformobjects finishes saving an object
> > it
> > > > > adds
> > > > > > > the
> > > > > > > > > > saved
> > > > > > > > > > > > > object's objectid to lsavedobjectids. That is also a
> > good
> > > > > way
> > > > > > > to tell
> > > > > > > > > > if
> > > > > > > > > > > > > there were validation issues with the object - if
> > there
> > > > > were
> > > > > > > the
> > > > > > > > > > object
> > > > > > > > > > > > > won't be saved and no objectid will be added to the
> > list.
>
> > > > > > > > > > > > > Blair
>
> > > > > > > > > > > > > On Mon, Dec 1, 2008 at 11:18 AM, Marco van den Oever
> > <
>
> > > > > > > > > > > > > [EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > > > > > Ok for the ones interested, as in this case every
> > answer
> > > > > is a
> > > > > > > new
> > > > > > > > > > > > > > answer you just have to generate a new uuid value
> > to set
> > > > > the
> > > > > > > > > > objectid
> > > > > > > > > > > > > > of the object:
>
> > > > > > > > > > > > > > <!--- if data exists show answer field --->
>
> > > > > > > > > > > > > > <cfif len(stobj.department)>
>
> > > > > > > > > > > > > > <cfset application.tai = CreateUUID()>
>
> > > > > > > > > > > > > > <ft:object typename="ticketanswers"
> > > > > > > objectid="#application.tai#"
> > > > > > > > > > > > > > lFields="answer" r_stPrefix="prefix"
> > legend="Answer" />
>
> > > > > > > > > > > > > > </cfif>
>
> > > > > > > > > > > > > > Then in the processform reformat the uuid so it
> > matches
> > > > > the
> > > > > > > format
> > > > > > > > > > > > > > used in the form names:
>
> > > > > > > > > > > > > > <!--- if a answer was entered set to db --->
>
> > > > > > > > > > > > > > <cfif isdefined('application.tai')>
>
> > > > > > > > > > > > > > <cfset application.tai =
> > > > > > > replace(application.tai,'-','','ALL') />
>
> > > > > > > > > > > > > > </cfif>
>
> > > > > > > > > > > > > > Then if the answer field was filled in, process the
> > value
> > > > > in
> > > > > > > the
> > > > > > > > > > db:
>
> > > > > > > > > > > > > > <cfif form[application.tai & 'answer'] gt 0>
>
> > > > > > > > > > > > > > <ft:processformobjects typename="ticketanswers">
>
> > > > > > > > > > > > > > <cfset stProperties.answer = form[application.tai &
> > > > > 'answer']
> > > > > > > />
> > > > > > > > > > > > > > <cfset stProperties.ticketobjectid = stobj.objectid
> > />
>
> > > > > > > > > > > > > > </ft:processformobjects>
>
> > > > > > > > > > > > > > </cfif>
>
> > > > > > > > > > > > > > Cheers
>
> > > > > > > > > > > > > > On Nov 30, 11:20 pm, Marco van den Oever <
>
> ...
>
> read more »
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"farcry-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/farcry-dev?hl=en
-~----------~----~----~----~------~----~------~--~---