While importing, an error is flashed: "The text "......" is too long. Text can have a maximum length of 50 characters."
How should I truncate the characters prior to importing ?
Thanks in advance
You can check your string value in this trigger Import::OnBeforeInsertRecord().
In this u have to check string length using STRLEN(fieldname).. and if it is greater than 50 than it depends on u what operation u have to do. Normally people taking initial 50 characters and you can do it using function COPYSTR(fieldname,1,50) and assign this value to that fieldname only.
for example
IF STRLEN(fieldName) > 10 THEN BEGIN
tableName.fieldName := COPYSTR(fieldName,1,10);
END
ELSE BEGIN
tableName.fieldName := fieldName;
END;
If the text in the tag is longer than the target variable (in this case some field), you cannot "Trim" the value before it is assigned to the field. You need to use text variable instead field as target and assign the value to the field manually in the OnAfterAssignVariable trigger of the tag.
Right now, the error is risen right when the value should be assigned to the field and there is no trigger before this action (like OnBeforeEvaluateField in dataport).
Comments
In this u have to check string length using STRLEN(fieldname).. and if it is greater than 50 than it depends on u what operation u have to do. Normally people taking initial 50 characters and you can do it using function COPYSTR(fieldname,1,50) and assign this value to that fieldname only.
for example
IF STRLEN(fieldName) > 10 THEN BEGIN
tableName.fieldName := COPYSTR(fieldName,1,10);
END
ELSE BEGIN
tableName.fieldName := fieldName;
END;
IF STRLEN("<Invoice>".Agency) > 50 THEN
"<Invoice>".Agency := COPYSTR("<Invoice>".Agency,1,50);
But, still it flashes the same error.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Following are the properties of the Agency field in the XMLport which is giving an error:
Indentation 1
NodeName Agency
NodeType Element
SourceType Field
SourceField <Invoice>::Agency
FieldValidate <Undefined>
AutoCalcField <Yes>
Width 0
MinOccurs <Once>
MaxOccurs <Once>
Do I need to change the SourceType to Text and assign the field through C/AL?
And can u see what's value is coming there in Agency field?
try following code
IF STRLEN(Agency) > 50 THEN
"<Invoice>".Agency := COPYSTR(Agency,1,50)
ELSE
"<Invoice>".Agency := Agency;
Specifying Agency instead of <Invoice>.Agency given an unknown vairable error.
Its giving error in CodeUnit? I didnt get u..
After the xmlport is called from codeunit, and xmlport is initialized, it gives the error.
Right now, the error is risen right when the value should be assigned to the field and there is no trigger before this action (like OnBeforeEvaluateField in dataport).
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.