Options

Wizard to create items

kjboloekjboloe Member Posts: 56
Hi
I would like to make a wizard to create items.
I have a problem when I use Item as SourceTable :
I would like the datasource to be blank so that I can fill the field as if it was done by using Item Card and create new, but I get the first record from the Item table.
Is there a way to make the datasource in create mode or is the solution to create a new table and use that as SourceTable ?
Kind regards

Kenneth Jarlshøi Bolø
Dynateam A/S

Comments

  • Options
    giulio.cipogiulio.cipo Member Posts: 77
    you colud use a new table where insert all field and when you confirm the insert of item you write in the right table.
    other solution is look at the other wizard in the sistem ( form 5077 for iteraction in 3.70)
  • Options
    alanperualanperu Member Posts: 23
    Hi,

    You do not have to have a sourcetable for a form. The New Form Wizard will let you create one without a table (unless that's changed in newer versions), or you can remove it from the form's properties after creation.

    You can then just use variables on the form to create the Item entry.

    I would try to avoid using an extra 'buffer' table to create these entries.
  • Options
    kjboloekjboloe Member Posts: 56
    Hi Allan

    I have tried that , but if make the form without a datasource and create a variable for it, I have problems with lookup, because I can't use tableRelation on a variable. Then I have to code the lookup and so on.
    Kind regards

    Kenneth Jarlshøi Bolø
    Dynateam A/S
  • Options
    kinekine Member Posts: 12,562
    If you create variable Items: Record 27, and in edit box you use in SourceExpression Items.Category (for example) - there is lookup...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • Options
    alanperualanperu Member Posts: 23
    Ok, you can still have the sourcetable as Item, but set the InsertAllowed and DeleteAllowed to 'No' on the form. You might also want to change the DataCaptionExpr so that you do not see the record number from the Item table.

    You can then add variables to the form. Drop on some textboxes, set the source of the textboxes to the variables AND you will be able to use table relations on the textboxes.

    You can then just have an 'Add' button that uses the values from the variables to create a new Item record and insert it.

    Let me know if you need any more help.
  • Options
    kjboloekjboloe Member Posts: 56
    Hi

    I have found a solution :

    1) I call a codeunit from form Item Card
    2) The codeunit call my wizard

    Codeunit :

    ItemRec.SETRANGE(ItemRec."No.",'');
    CreateItemWizard.SETTABLEVIEW(ItemRec);
    CreateItemWizard.SETRECORD(ItemRec);
    CreateItemWizard.RUNMODAL;

    Then after I have keyed in the Item I insert the record, this works fine.

    My wizard have now Item as SourceTable

    Thank for all your help \:D/
    Kind regards

    Kenneth Jarlshøi Bolø
    Dynateam A/S
  • Options
    kjboloekjboloe Member Posts: 56
    New solution to the problem.

    I now call my wizard directly from Item Card.

    I have created a global variable for the field No. (ItemNumber)

    On the trigger OnOpenForm :
    SETRANGE("No.",'');

    On the trigger OnValidate :
    I create a local variable NewItem as Record Item
    NewItem."No." := ItemNumber;
    NewItem.INSERT;
    SETRANGE("No.",NewItem."No.");
    On the trigger OnAfterValidate :
    CurrForm.UPDATE(FALSE);

    \:D/ \:D/ \:D/ \:D/ \:D/ \:D/ \:D/ \:D/ \:D/ \:D/
    Kind regards

    Kenneth Jarlshøi Bolø
    Dynateam A/S
Sign In or Register to comment.