Skip to main content

Initializing the table based on Parent Table using "ModifiedField" Method

Initialize or get the data from Parent Table to Child Table.And this functionality is done based on Foreign key .
Below is the Lookup functionality implemented to get the data from Parent Table to Child table using Init Method
Step 1 : Created Parent Table with name Product Category (ProductCategoryID , Product_Category)and entered some data in it .

Step 2: Now Created child table with Columns (Product ID, Product Name , List Price ,Standard Cost,Quantity ) And these columns are related to Products.Now Create two more Columns one Category(String) and other Category Price  (Real Datatype) .
Note: In my case  I had created the child table with name "InventoryProduct"

Step 3 : Get All the values of ProductCategory column  from Parent Table to child table column Category :
   1. Create Relation in Child Table below is the .I had create the Relation name as "GetCategories" .And specified my parent table name in "Properties Tab -> Table"


  2: Create the Normal Relation , By right clicking the relation name
  3:  Now select the Category Field which is column of Child Table
    And as shown below select the column ProductCategory of parent table      

     automatically relation will  get's created in child table:

Note: If you get 2 coumn values in child table column "Category" Please drag and drop the "ProductCategory" column in " AutoLookup" of  "Field Group" Section.
Step 4:Create the "ModifiedField" method and apply below code before Super() method
 ProductCategory productc;
    if(_fieldId==fieldNum(InventoryProducts,Category))
    {
      select productc where productc.Product_Category== this.Category;
      this.CategoryID=productc.ProductCategoryID;
    }

Comments

Popular posts from this blog

Insert and doindert method

Below is the Syntactical Code which is used to insert the data into table Insert() Method program InventoryProducts IP; IP.Category="Candy"; IP.ProductCode="NWTCA-48"; IP.ProductName="Northwind Traders Chocolate"; IP.StandardCost=9.5625; IP.ListPrice=12.75; IP.QuantityPerUnit="10 pkgs"; IP.insert(); doInsert() Method  program  InventoryProducts IP; IP.Category="Candy"; IP.ProductCode="NWTCA-48"; IP.ProductName="Northwind Traders Chocolate"; IP.StandardCost=9.5625; IP.ListPrice=12.75; IP.QuantityPerUnit="10 pkgs"; doinsert(); If you see the Above code it is similar in both programs except last lines insert() & doinsert() . But the main difference is when insert() method get triggers then it calls super() method which take care's to insert the values in table. Also , the insert() method  is used to insert values in table based on condition (true or false) DoInsert() method ,  pe...