?
Solved

cfinvoke inside cfscript

Posted on 2010-01-11
7
Medium Priority
?
1,776 Views
Last Modified: 2012-05-08
I need to invoke a cffunction from inside a cfscript.  

<cfscript>
// to unlock record when browse away
      function UnlockRecord()
            {
//                  <cfinvoke component="control.cfc.basic" method="ReleaseLock" section="Individuals" recordID= "#val(form.indivNum)#" returnvariable="Release" />;
            Return;
            }
</cfscript>

I'm getting an error about the cfscript tag needing an ending tag.
0
Comment
Question by:lantervj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 26287305
can you simly do this. Or something similar to this

<cfscript>
 obj =  CreateObject("component","pathToThe CFC") ;
obj. ReleaseLock(#val(form.indivNum)#);

</cfscript>
0
 
LVL 52

Expert Comment

by:_agx_
ID: 26287535
> I need to invoke a cffunction from inside a cfscript.

You can't.  Using regular CF tags inside cfscript is not allowed.  Either use CreateObject() as Erik suggested, or create a CFFunction that does the cfinvoke call. Then call that function from within your <cfscript>.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 26287563
Actually now that I look at the code more closely  ... why do you need a function for this?  You're already using a CFC _with_ a function?
0
Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

 

Author Comment

by:lantervj
ID: 26289918
When I exit a page, I have some "browse away" code and if the user clicks on the back button the code to unlock the record they were just in gets bypassed.  I need to execute that unlock function but I'm in browse away javascript when it happens.
0
 
LVL 52

Expert Comment

by:_agx_
ID: 26290029
Well you can't execute CF code from javascript anyway.  CF runs on the server, and javascript on the client (browser).  So you'd have to use ajax to do another request to the server to run that code anyway.
0
 

Author Comment

by:lantervj
ID: 26290137
good point. Maybe the best thing would be to disable the back button.  But I think I would get the same problem if they just closed the tab/page.
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 26290464
> Maybe the best thing would be to disable the back button

I think the best thing to do is to "try" and prevent them, but have a good backup plan in case it doesn't work.  Which it won't much of the time.  While there are many options that "sort-of" work. There is really no bullet proof way to prevent this.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question