I have created a dataport (import), which is going to save data to different tables (customer, vendors, job) at the same time.
Right now, I am getting an error that a particular customer type already exists. So, I tried writing a condition statement to take care of it but its didnt work.
It said i have specified an unknown variable, rec and xrec. How can i check it without using the rec and xrec variable. Thats what I have always used to do these sorta checks???
IF rec.Customer."No." = xrec.Customer."No." THEN
Customer.MODIFY(true);
So basically what I want to do is, check if a particular Customer."No." exists in records. If it does, then modify it to import the information from the one in the excel file.
Any suggestions??
Comments
It gives me the same message. That a particular customer number already exist.
I just want it to modify it, even if it already exists in record and AutoReplace doesnt work because I am importing to multiple tables at the same time.
Is that all your code?
do you have an INSERT somewhere?
Are you importing into variables & mapping back to nav fields or are you going direct to nav fields?
What other type of customer is there? :-k
http://www.BiloBeauty.com
http://www.autismspeaks.org
You start off with modify then you assign all these variables then insert?
what exactly are you modifying at that point?
why not group them with if--then begin--end else begin--end?
because if you don't group it with a condition the insert line is going to run if you like it or not.
and give you an error if it already exists.
or lose the first modify & change the last insert line to
if not insert then modify;
you have to be careful with autoreplace - because "i believe" it will clear out any fields you are not defining instead of just updating a few fields.
now if this basically an insert dataport you can use
if customer.get("no.") then begin
currdataport.skip;
end else begin
.
.
.
insert; //not even sure you need to tell it to insert if you have your auto.. properties set correctly.
end;
http://www.BiloBeauty.com
http://www.autismspeaks.org
1) Check if the Customer No. exists. If it does, replace the information in that record with the new information from the excel file. Hence the Modify function.
2) Even if the Customer No. does not exist. Create a new record and initialize all the information from the excel file to the fields in the table.
One of the heading in my excel file was clfname, which got mapped to Customer."First Name". Hence this line of code: Customer."First Name" := clfname; ..... and so on.
The exact Error That I am getting right now is this:
"Customer C1XXXXXX already has a contact business relation with contact CTXXXXXX"
The way I interpret this error was that, this record already exists in the system. Thats why, I wanted to write the If condition to modify the information even if the record exists.
//assignments to keys, e.g.
customer."no." := 'XXX'; //or
vendor."no." := 'YYY'; // and so on
IF INSERT THEN BEGIN
{this is to place your action when it sucessfully inserting new customer no. or new vendor no.}
... // your statements
END ELSE BEGIN
{this is to placeyour action when it CANNOT insert, means, "No." is already exist}
... // your statements
END;