Hey guyz,
I created a dataport to import some information from a csv file.
It creates a No. for the record but it doesnt import any of the information. All the fields are left blank.
I tried debugging it, it doesnt seem to read any of the information from the excel file. All the fields from the excel file are blank in the debugging mode.
I have created all the variables in the C/AL Global, and Dataport fields. I have set import to yes, FileFormat to variable, FieldSeperator to , ,Record and dataitem seperator to NewLine. I have set AutoSave, AutoUpdate, and AutoPrelace to YES.
I dont know what else I could be missing. All the code I have written is in OnAfterImportRecord.
Any idea why it might be doing wrong since it doesnt seem to read the csv file???
CLEAR("Fixed Asset");
"Fixed Asset".INIT;
"Fixed Asset"."No." := "No.";
"Fixed Asset".Description1 := Description1;
"Fixed Asset"."Description 2" := Description2;
"Fixed Asset"."Serial No." := "Serial No.";
"Fixed Asset"."Office No." := "Office No.";
"Fixed Asset"."Make/Brand Name" := "Make/Brand Name";
"Fixed Asset"."Model No." := "Model No.";
"Fixed Asset"."Responsible Employee" := "Responsible Employee";
"Fixed Asset"."FA Class Code" := "FA Class Code";
"Fixed Asset"."Cost Center Code" := "Cost Center Code";
"Fixed Asset"."Shortcut Dimension 7 Code" := "Shortcut Dimension 7 Code";
"Fixed Asset".INSERT(TRUE);
Comments
http://www.BiloBeauty.com
http://www.autismspeaks.org
http://www.BiloBeauty.com
http://www.autismspeaks.org
Trigger - OnAfterImportRecord()
The Table key is "No." field. What would I have to with the key field of the table??
I have to validate the values...i didnt know that. The last dataport I created, i never validated all the values and the dataport worked fine.
I import them in the order you would naturally manually enter them. Validating where needed. You can always throw a message on the code , say after you get the " no." fields throw MESSAgE('%1',"no.");
To see if it's even picking up the value. Then that helps you find the problem. It will either be while importing or after importing. Then you can narrow you focus.
http://www.BiloBeauty.com
http://www.autismspeaks.org
http://www.BiloBeauty.com
http://www.autismspeaks.org
I am not sure why they are blank.
I took out all the other lines from the CSV file except one and its still empty. It creates a Job No. for that line. But the rest of the line is blank. None of the information gets imported.
Since I can't See i have ask if you've filled in the data port fields.
You also say it finds nothing then you said it imported just the "no."
Please be specific on exactly what's happening
http://www.BiloBeauty.com
http://www.autismspeaks.org
http://www.BiloBeauty.com
http://www.autismspeaks.org
No. field is increment using a No. Series. Before a record gets inserted into the database, it has its own unique No.
Each line in the CSV file will have a unique No. field (this will help us differentiate between different records).
After the unique No. has been created using the No. Series, information from the CSV file is suppose to be assigned to different variables in that table.
I have created global variables and I am mapping back to them.
Also, make sure your trigger you are using is correct and nothing on the others
http://www.BiloBeauty.com
http://www.autismspeaks.org
"Fixed Asset"."No." := "no.";
To "Fixed Asset".validate(No.",yourNOvariable);
Do you get a message?
Also in your code I see nothing about getting a number series? Why?
http://www.BiloBeauty.com
http://www.autismspeaks.org
You said you've made data ports before, with what I told you you should be able to figure out the problem.
[-o<
http://www.BiloBeauty.com
http://www.autismspeaks.org
http://www.BiloBeauty.com
http://www.autismspeaks.org
If so your code is clearing the record you are importing and mapping each fields on it's own as code in the OnAfterImportRecord is having an implicit WITh DO on the DataItem variable "Fixed Asset". So actually your could as saying:
Never stop learning
Van Vugt's dynamiXs
Dutch Dynamics Community
so if your using the lookup to fill in the dataport fields then your bypassing the variables.
change your variable name's to ImportedNo, ImportedDesc1,ImportedDesc2, etc.
manually type in these names into the dataport fields.
then change your code..
"Fixed Asset"."No." := ImportedNo;
"Fixed Asset".Description := IMportedDesc1;
etc.
etc.
also the final check I can mention is to add a "No." manually into the csv file.
if it works with a solid number in the csv file then you know using your number series isn't working properly.
you can also add a line to the table in questions & use your dataport to export the info to a csv to see if it's in the same format as the csv file you are using.
all the solutions mentions should help you find where it's going wrong.
http://www.BiloBeauty.com
http://www.autismspeaks.org
If you look at the code on the table you will see..
Description - OnValidate()
IF ("Search Description" = UPPERCASE(xRec.Description)) OR ("Search Description" = '') THEN
"Search Description" := Description;
So if you aren't validating how are you going to fill the Search Description field?
that's where 1 manual entry line compared to 1 dataport import line can show you what's missing. I would also go back to the "other" dataport you created and do a comparision and fix it if needed, remember it doesn't necessarily mean validate ALL the values, just the right ones. Fixed Asset table doesn't have a "Job No." field are you referring to the "No." field? The fixed assets table has a "No." field & A "No. Series" field. are you sure your not confusing these?
this shouldn't be a hard dataport to create.
http://www.BiloBeauty.com
http://www.autismspeaks.org
Check if Dataport FieldSeparator is <,> as you are using a CSV file
:thumbsup: