So, I'm relatively new to this list. Posted a couple of unanswered questions the other day.

So, to balance out the universe, I'll offer up a snippet that I find useful.

The attached method goes inside of a reactor generated record object. (In my case PermissionRecord.cfc)

It basically deletes current Link records and then adds new ones based on what you pass in.

Technically, it would be better to only delete the ones not in the list passed in and then add the ones that aren't already there.
But that wasn't nearly as clean or neat to write. And I'm writing a fairly low-traffic site. So I'm not going to sweat the miliseconds.

Let me know it anyone finds it useful.

--
Chris Phillips
www.dealerpeak.com
Senior Application Developer
        <cffunction name="UpdateFuseActions" access="public" hint="I set a 
Permissions link to FuseActionIDs." output="true" returntype="void">
                <cfargument name="Fuseactions" required="true" type="string" />
                <!--- Private Instance Vars --->
                <cfset var fCollection = 
this.getPermission_FuseActionLinkIterator() />
                <cfset var fLinkRecord = "" />
                <!--- Delete This Permission's FuseAction Links --->
                <cfloop condition="#fCollection.hasMore()#">
                        <cfset fLinkRecord = fCollection.getNext() />
                        <cfset fLinkRecord.delete() />
                </cfloop>
                <!--- Reset Iterator --->
                <cfset fCollection.reset() />
                <!--- Add Links To FuseActions This Permission Has --->
                <cfloop list="#trim(FuseActions)#" index="fID">
                        <cfscript>
                                fLinkRecord = 
_getReactorFactory().createRecord('Permission_FuseActionLink');
                                fLinkRecord.setPermissionID(getPermissionID());
                                fLinkRecord.setFuseActionID(fID);
                                fLinkRecord.save();
                        </cfscript>
                </cfloop>
        </cffunction>






 

-- Reactor for ColdFusion Mailing List -- [email protected]
-- Archives at http://www.mail-archive.com/reactor%40doughughes.net/

Reply via email to