Options

how to assign filed from table to another

MRQMRQ Member Posts: 73
hi

ihave problem to assign the filed "Docuomant type" and Documant No."
and "Line No." from Sales Line to another table called TEST i add Button
in the sales order sub form and write this code OnPush Event
//GetSalesLine is function in the TestCard Form
// the 99508 is the testCard form id 
testCard.GetSalesLine("No.","Document Type","Document No.");
FORM.RUN(99508);

and in the GetSalesLine Function i try to assign the function parameter to the filed Put Nathing happened
//GetSalesLine have 3 parameter 
// No code[20]
// Type option
//DocNo code[20]


"No.":=No;
"Document Type":=Type;
"Document No.":=DocNo;

any one can help plz ](*,)

Comments

  • Options
    HalMdyHalMdy Member Posts: 429
    Not sure, but ...

    In place of calling the form by FORM.RUN() , use TestCard.RUN instead, so you are sure you work on the same instance of the form ...
  • Options
    JanVJanV Member Posts: 34
    Just try

    SalesLine.Get(Type,DocNo,No)

    in the getsalesline function. With your code you're trying to modify the record itself (even than you wold have to insert an salesline.modify).
  • Options
    MRQMRQ Member Posts: 73
    thanx halmdy janv

    but the problen not solve yet :cry:

    janv this the function GetSalesLine after modifying the code

    SalesLine.GET(Type,DocNo,LineNo);
    "Line No.":=SalesLine."Line No.";
    "Document Type":=SalesLine."Document Type";
    "Document No.":=SalesLine."Document No."; 
    

    no error but the filed in the TestCard still empty ](*,) ](*,)
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Have you tried giving the record to the form as parameter

    Form.RUN(Form::"Te Form", Record);
  • Options
    JanVJanV Member Posts: 34
    Ok, first of all delete following code in yor function:
    "Line No.":=SalesLine."Line No.";
    "Document Type":=SalesLine."Document Type";
    "Document No.":=SalesLine."Document No."; 
    

    as with this code you're trying to assign new values.

    Maybe you can replace the "get"-statement throug a form.setrecord like in

    form.setrecord(salesline) and then run the form.

    BTW, what do you mean with "button in subform"? Did you really put it into the subform or did you just put it next to the other buttons?
  • Options
    MRQMRQ Member Posts: 73
    hi Mark Brummel thanx man

    but i cant use
    Form.RUN(Form::"Te Form", Record);
    
    

    couse the 2 tables have deferunt fileds just 3 of the fileds shared between the two table
  • Options
    MRQMRQ Member Posts: 73
    JanV

    man there is no function called
    .setrecord
    

    whit the form object

    :(
    JanV wrote:

    BTW, what do you mean with "button in subform"? Did you really put it into the subform or did you just put it next to the other buttons?

    yes i put it into the subform
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Yes, but the record thing must be a variable, based on the record from the form.

    For example,

    If you want to open the item card from a sales line, the "No." from the salesline is the "No." from the item.

    You should the define an Item record variable and to something like
    Item.GET(Rec."No.");
    Form.RUN(FORM::"Item card", Item);
    

    I Hope this clarifies things.
  • Options
    MRQMRQ Member Posts: 73
    Mark Brummel you r right but in my case there is no data in the

    TEST Table
    so if i applay the folwing code
    Test.GET(Rec."No."); 
    Form.RUN(FORM::"Test card", test); 
    

    this error come out
    test No. 1996-s does not exist
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    What is the key of the test table?

    You have the primary key available or do you have other link fields?

    If you for instance know the name of an item you can do
    Item.Setrange(Name, IKnowTeName);
    Form.Run(Form::"item card", ITEM);
    

    Instead of the get.
  • Options
    MRQMRQ Member Posts: 73
    ok mark i think there is misunderstanding; my case is
    I have no perdifined items, let say I want to sell tickets but each ticket is much diferrent than the others and this diferrence is impossible to be preknown so we can't define each ticket as an individual item so we defined (Ticket category) as an item and therefore when you select the (Ticket category) in the sales order a new window must open to allow me to enter the details of this ticket. Now the primary key for the sales lines consists of three fields; document type, document no. and the line no. The primary key for the ticket window -the new window- is the same.

    My problem is how to copy the values found in those fields in the sales lines to the new window -ticket card- because we want to link the ticket to its corresponding sales line.

    Thanks again man for your precious time
  • Options
    Marije_BrummelMarije_Brummel Member, Moderators Design Patterns Posts: 4,262
    Ok, I think I am beginning to understand.

    You could try to do something like this. (Assuming there is no ticket)
    Ticket.init;
    Ticket."Document No." := SalesLn."Document No.";
    Ticket."Document Type" := SalesLn."Document Type";
    Ticket."No." := SalesLn."No.";
    Ticket.INSERT;
    FORM.RUN(Form::"Ticket Card", Ticket);
    

    And if the ticket exists:
    Ticket.GET(SalesLn."Document No.". SalesLn."Document Type", SalesLn."No.");
    FORM.RUN(Form::"Ticket Card", Ticket);
    
  • Options
    MRQMRQ Member Posts: 73
    thanx mark its work now \:D/ thank u again
Sign In or Register to comment.