CU created can't work

Dear All,

I would like to ask you about CU I made that unable to work when I write it to C/AL editor of a form designer. The coding as follows:
record.COPY(Rec);
CurrForm.SETSELECTIONFILTER(record);
IF record.FIND(’-’) THEN BEGIN
record.“field” := code;
CU.aaa(record,record);
END;

all records are in the C/AL Global

In the CU itselfs :
C/AL Global function(jjj : Record “xxx”;AppltoDocType : Option;ApplytoDocNo2 : Code[20];ssss

nextlineno := nextlineno +10000;

record2.INIT;
record2.“Document Type” := record1.“Document Type”;
record2.“Document No.” := record1.“Document No.”;
record2.“hhh” := record1.“hhh”;
record2.“Resource No.” := record1.“Resource No.”;
record2.“Allocation Date” := record1.“Allocation Date”;
record2.INSERT;

Createwww(VAR qqq : Record “ddd”;jjj : Record “xxx”)
IF NOT record1.RECORDLEVELLOCKING THEN
record1.LOCKTABLE(TRUE,TRUE);
nextline := record.“field”;
record2.SETRANGE(“Document Type”,record1.“Document Type”::Order);
record2.SETRANGE(“Document No.”,record1.“Document No.”);
REPEAT
record2.SETRANGE(“Document No.”,record1.“No.”);
IF NOT record2.FIND(’-’) THEN
xxx(record,record2.“Document Type”::Order,
record2.“Document No.”,record.“Document Type”,record.“No.”,
record.Description,nextline);
UNTIL record.NEXT = 0;

Record 1 = record 2 and record is not as same as record 1 and record 2.

My purpose with the coding is similar with form 5805 tab functions. I would welcome for your kindness to reply and answers. tku…

Rgds,

When you select to run the CU run the CU with the proper function

CU.Createwww(record,record);

In that function of the CU you do not read Record1 only lock it[:^)] I think you are also confusing yourself between which record you want to use and you could the put the coding of function below the IF NOT Record2.FIND(’-’) THEN and use a BEGIN and END

IF NOT Record2.FIND(’-’) THEN BEGIN

coding goes here from function

END;

Hope this helps you. [:D]


Dear Albievh,
Tks a lot for your answer, I’ll check it but I am not sure it solved before I run and it works good.



Rgds,
Mark