Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
I'm having trouble figuring out how to pass an attribute value to a simple acl function that formats and returns the value to save it to a variable. The attribute is "revdate" and the eic is "cmm"
<e-I-c gi="cmm>
...
<att>
<specval attname="revdate" attval="#ANY">
<fillval attname="myfuncs::format_date" attloc="system-func" fillcat="savetext" fillchar="conrule">
<charsubset>
<savetext textid="issuedate.txt">
</charsubset>
Plus I know I'm not declaring the function correctly:
function format_date(window,oid)
...
local date=oid_attr(oid, ?);
...
Any help is appreciated.
Solved! Go to Solution.
Hi Caroline,
It doesn't need to be that complicated.
In the FOSI:
<fillval attname="myfuncs:formatdate" attloc="system-func" fillcat="savetext" fillchar="conrule">
The following ACL gets the attribute value using oid_attr and oid_current_tag. Then you can use substr to format the string.
function formatdate(window,oid)
{
$d=oid_attr(oid_current_tag(),"revdate");
...
return ...;
}
If you have my book, you can search for "system-func" to see various examples of how to use ACL with FOSI. If you don't have my book, it is available at http://fosiexpert.com/Practical-FOSI.html.
Good luck!
Suzanne
Hi Caroline,
Sorry, I don't have a revdate function handy to share. You need oid_current_tag() to provide the oid for oid_attr.
The FOSI code should work. However, you do not need the specval to test if the attribute has a value. If it doesn't, the fillval is automatically ignored. The formatting engine handles error checking like that so you don't have to 🙂
Good luck!
Suzanne Napoleon
"WYSIWYG is last-century technology!"
Thanks, Suzanne, I didn't know about the error checking.
But what I wanted to know is if there is a way to pass an attribute as a parameter to an ACL function. I haven't found any examples doing that. I had to create a second function to pass the revdate attribute to the format_date function:
<fillval attname="myfuncs:get_revdate" attloc="system-func" fillcat="savetext" fillchar="conrule">
...
function get_revdate(window,oid) {
local v;
v = format_date(window,oid, "revdate")
return v
}
I didn't like hardcoding revdate in the ACL. I wanted to do something like this:
<fillval attname="myfuncs::format_date('revdate')" attloc="system-func" fillcat="savetext" fillchar="conrule">
function format_date(window, oid, attr) {
...
local date=oid_attr(oid, attr);
...
Hi Caroline,
It doesn't need to be that complicated.
In the FOSI:
<fillval attname="myfuncs:formatdate" attloc="system-func" fillcat="savetext" fillchar="conrule">
The following ACL gets the attribute value using oid_attr and oid_current_tag. Then you can use substr to format the string.
function formatdate(window,oid)
{
$d=oid_attr(oid_current_tag(),"revdate");
...
return ...;
}
If you have my book, you can search for "system-func" to see various examples of how to use ACL with FOSI. If you don't have my book, it is available at http://fosiexpert.com/Practical-FOSI.html.
Good luck!
Suzanne
Thanks so much, Suzanne!