www.Inmagic.com    Inmagic Forums    Inmagic Forums  Hop To Forum Categories  Scripting    Quality rating of reports
Go
New
Find
Notify
Tools
Reply
  
-star Rating Rate It!  Login/Join 
Posted
I am very new to scripting, so please excuse me if the answer to my query is/should be obvious.

I have a database indexing reports which may be either subject to a QA audit or not (field qq = Y or N). The reports will be assessed for quality against a number of criteria, each of which will receive a numerical score. A field, ts, totals this 'quality score'.

The problem:

Reports will be categorised: Excellent, Good or Poor, based upon the total score - but the 'grade bands' are different for QA'd and non- QA'd reports. My script (below) is intended to check first of all if the 'qq' field has been completed or not, then, dependent upon value ,it assigns a quality rating to the 'qr' field.

The script fails (of course!). Can anyone point out the error of my ways, and set me on the right track?


function onRecordSave()
{

var qq; //identify if report is QA'd or not
var ts; //set total quality rating score

qq = Form.boxes(qq);
ts = Form.boxes(ts);

if (qq == "Y") //identifies QA'd reports

if (ts <10)
Form.boxes("qr").content = "Poor";

else if (ts >9 && ts <18)
Form.boxes("qr").content = "Good";

else if (ts>17)
Form.boxes("qr").content = "Excellent";

else if (qq == "N") //identifies non QA'd reports

if (ts <6)
Form.boxes("qr").content = "Poor";

else if (ts >5 && ts <14)
Form.boxes("qr").content = "Good";

else if (ts>13)
Form.boxes("qr").content = "Excellent";


else if (qq == "") //identifies records with no entry in field to indicate QA status
return;


}
 
Posts: 39 | Location: Brixham, Devon, UK | Registered: Wed May 22 2002Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
1. You are using vars qq and ts to access the Form.boxes collection before they have been assigned a value or even a variable type.

To fix:

var qq = Form.boxes("nameOfQQBox").content;
var ts = Form.boxes("nameOfTSBox").content;

2. Box content returns as a string, so you need to cast ts to an integer before testing < 10.

To fix:

// parseInt(string) is a built-in js fxn
var intTs = parseInt(ts);
if (intTs < 10)
//etc.

3. You must use curly braces with if/elseif when nested content has more than one line.

To fix:

if (qq == "Y")
{
if (ts < 10)
// etc.
}


Peter Tyrrell, MLIS
Senior Consultant
Andornot Consulting Inc.
http://www.andornot.com/about/developerblog
 
Posts: 179 | Location: Vancouver, BC, Canada | Registered: Thu September 20 2001Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
Thanks Peter,

I am grateful for the advice, and hopefully will have a chance to look at this later today. I am trying to strike a reasonable balance betwen investment in learning some of the basics of jscript for DBTextworks - as I believe it DOES have the potential to hugely add to our capabilities in a very cost effective manner - WITHOUT getting away from the core part of my job and encroaching into the realms of the programmers.

Best regards.
 
Posts: 39 | Location: Brixham, Devon, UK | Registered: Wed May 22 2002Reply With QuoteEdit or Delete MessageReport This Post
Posted Hide Post
Thanks Peter,

I am grateful for the advice, and hopefully will have a chance to look at this later today. I am trying to strike a reasonable balance between investment in learning some of the basics of jscript for DBTextworks - as I believe it DOES have the potential to hugely add to our capabilities in a very cost effective manner - WITHOUT getting away from the core part of my job and encroaching into the realms of the programmers.

Best regards.
 
Posts: 39 | Location: Brixham, Devon, UK | Registered: Wed May 22 2002Reply With QuoteEdit or Delete MessageReport This Post
 Previous Topic | Next Topic powered by eve community  
 

www.Inmagic.com    Inmagic Forums    Inmagic Forums  Hop To Forum Categories  Scripting    Quality rating of reports