Jump to content

GetFieldValue requires more than 1 arguement Issue


ryanceot

Recommended Posts

I'm using the following code and receive an "Uncaught Exception: TypeError: GetFieldValue requires more than 1 argument.

 

Any help would be greatly appreciated.

 

 

---

 

 

//Calling data from an external data file

var ex = new ExternalDataFileEx('ppfinalfltb.csv', ',');

var cursor = ex.SortBy('KEY1');

var rec = cursor.FindRecords(Field('KEY1'));

 

 

if (((ex.GetFieldValue('RDAT01') !='') && ex.GetFieldValue('DITKT#') != '') && (ex.GetFieldValue('DDTKT#') != ''))

 

{

return ex.GetFieldValue('DITKT#') + ', ' + ExField('DDTKT#');

}

 

if ((ex.GetFieldValue('RDAT01') !='') && (ex.GetFieldValue('DITKT#') != ''))

 

{

return ex.GetFieldValue('DITKT#');

}

 

if (ex.GetFieldValue('GROUND') !='')

 

{

return RawText('Our records indicate that have elected to make your own flight arrangements. Therefore, we do not have your ticket number(s) on file.');

}

 

return '';

Link to comment
Share on other sites

Yes, GetFieldValue requires two arguments: the record number (i.e. the row in the spreadsheet) and the name (or index) of the field (i.e. the column in the spreadsheet).

 

Also, FindRecords returns an array of all records which match the criteria. If you want to return just a single record number, you want to call FindRecord (without the "s" at the end) on the XDF directly, instead of using a cursor.

 

So you need to do this:

//Calling data from an external data file
var ex = new ExternalDataFileEx('ppfinalfltb.csv', ',');
var rec = ex.FindRecord('KEY1', Field('KEY1'));


if (((ex.GetFieldValue(rec, 'RDAT01') !='') && ex.GetFieldValue(rec, 'DITKT#') != '') && (ex.GetFieldValue(rec, 'DDTKT#') != ''))
{
return ex.GetFieldValue(rec, 'DITKT#') + ', ' + ex.GetFieldValue(rec, 'DDTKT#');
}

if ((ex.GetFieldValue(rec, 'RDAT01') !='') && (ex.GetFieldValue(rec, 'DITKT#') != ''))
{
return ex.GetFieldValue(rec, 'DITKT#');
}

if (ex.GetFieldValue(rec, 'GROUND') !='')
{
return RawText('Our records indicate that have elected to make your own flight arrangements. Therefore, we do not have your ticket number(s) on file.');
}

return '';

Of course, you can always make yourself a convenience function as a shortcut:

//Calling data from an external data file
var ex = new ExternalDataFileEx('ppfinalfltb.csv', ',');
var rec = ex.FindRecord('KEY1', Field('KEY1'));

function GetXDFValue(name)
{
   return ex.GetFieldValue(rec, name);
}

if (((GetXDFValue('RDAT01') !='') && GetXDFValue('DITKT#') != '') && (GetXDFValue('DDTKT#') != ''))
{
return GetXDFValue('DITKT#') + ', ' + GetXDFValue('DDTKT#');
}

if ((GetXDFValue('RDAT01') !='') && (GetXDFValue('DITKT#') != ''))
{
return GetXDFValue('DITKT#');
}

if (GetXDFValue('GROUND') !='')
{
return RawText('Our records indicate that have elected to make your own flight arrangements. Therefore, we do not have your ticket number(s) on file.');
}

return '';

I'd be inclined to go a bit further and put those values into their own variables to make the code a bit easier to follow:

//Calling data from an external data file
var ex = new ExternalDataFileEx('ppfinalfltb.csv', ',');
var rec = ex.FindRecord('KEY1', Field('KEY1'));

function GetXDFValue(name)
{
   return ex.GetFieldValue(rec, name);
}

var RDAT01 = GetXDFValue('RDAT01');
var DITKT = GetXDFValue('DITKT#');
var DDTKT = GetXDFValue('DDTKT#');
var GROUND = GetXDFValue('GROUND');

if (RDAT01 && DITKT && DDTKT)
   return DITKT + ', ' + DDTKT;

if (RDAT01 && DDTKT)
   return DITKT;

if (GROUND)
   return RawText('Our records indicate that have elected to make your own flight arrangements. Therefore, we do not have your ticket number(s) on file.');

return '';

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...