Friday 4 July 2014

Manually Restore an MSSQL Database in SQL Management Studio

Hi Everyone,

If you need to manually restore an SQL Database in Management Studio you can follow the instructions below for the version of SQL Server running on your server.

SQL 2012:
  1. Log onto SQL Server Management Studio.
  2. Navigate to the database you wish to restore.
  3. Right Click > Tasks > Restore > Database.
  4. Once on the General tab set the source to Device > Select Backup Device > Add > Navigate to the .bak file you're restoring to.
  5. Ensure The Destination Database is the correct one.
  6. Select the Options tab.
  7. Check "Overwrite the existing database (WITH REPLACE)" and "Close existing connections to destination database".
  8. Uncheck "Take tail-log backup before restore".
  9. Click OK.
Why we uncheck the Take tail-log Backup Before restore??
Tail-log backups are new to SQL Server 2005. The tail-log backup captures records on the transaction log that were written since the last transaction log backup. If you’re going to restore a database to the point of failure, then you need to take a tail-log backup before you start the restore operation.
If you’re going to restore to a point in time prior to the last transaction log backup, if you’re moving the database from one server instance to another, or if you’re overwriting the existing database, then you won’t need a tail-log backup. If the transaction log is damaged and you can’t take a tail-log backup, then you must restore without one.
SQL 2008:
  1. Log into SQL Server Management Studio.
  2. Navigate to the database you wish to restore.
  3. Right click > Tasks > Restore > Database.
  4. Once on the General tab select "From Device" for the source for restore, then navigate to the .bak file you're restoring to.
  5. Ensure the Destination for restore is set to the correct database.
  6. Select the Options tab.
  7. Check "Overwrite the existing database (WITH REPLACE)"
  8. Click OK

Friday 29 November 2013

How To Find a User's Security Identifier (SID) in Windows

 Hi to All,

It'll take less than a minute to find a user's SID in Windows.

Here's How:

  1. Open Command Prompt.
  2. Once Command Prompt is open, type the following command exactly as shown here, including spaces or lack thereof:
    wmic useraccount get name,sid
    and then press Enter. 
  3. You should see a table, similar to the following, displayed in the Command Prompt window:
    Name            SID
    Administrator   S-1-5-21-1180699209-877415012-3182924384-581
    Guest           S-1-5-21-1180699209-877415012-3182924384-604
    Bob             S-1-5-21-1180699209-877415012-3182924384-1342
    Test            S-1-5-21-1180699209-877415012-3182924384-1974
    Piyush          S-1-5-21-1180699209-877415012-3182924384-10347
    This is a list of each user account in Windows, listed by user name, followed by the account's corresponding SID.
    1. How To Find User's SIDs in the Registry:
      You can also determine a user's SID by looking through the ProfileImagePath values in each S-1-5-21 prefixed SID listed under theHKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList key.
      The ProfileImagePath value within each SID-named registry key lists the profile directory, which includes the user name.
      For example, the ProfileImagePath value under the S-1-5-21-1180699209-877415012-3182924384-1004 key on my computer is C:\Users\test so I know that the SID for the user "Tim" is "S-1-5-21-1180699209-877415012-3182924384-1974".
      Note: This method of matching users to SIDs will only show those users who are logged in or have logged in and switched users. To continue to use the registry method for determining other user's SIDs, you'll need to log in as each user on the system and repeat these steps. This is a big drawback so, assuming you're able, you're much better off using the wmic command method above.
     
      

Wednesday 28 August 2013

Creation of Item or Product and Product master in Dynamics AX 2012

Here we are going to discuss how to create a product and Product master(Items).

In 2012, ‘Item’ is replaced with ‘Product’. One cannot find an item master in Inventory Management Module, there is a separate module for item/product creation. The Name of that module is ‘Product Information Management’.
There are two types of Products in 2012. They are
1. Product
2. Product Master
1. Product:
These are clearly identifiable products that do not have variations associated with them. You can think of them as standard or base products. Use the Products list page in the Product information management module to view and manage products.
2. Product Master:
These serve as templates or models for variants. The variants of a product master can be either predefined or created in sales scenarios by using a product configurator. A product master is associated with one or more product dimensions, or for some configurators, product attributes. Use the Product master’s list page in the Product information management module to view and manage product masters
To access Product and Product Masters go to Product Information Management a Common Forms a Products a Products /Products Masters.
 
Product Creation Process:
  • To create product go to Product Information Management à Common Forms à Products à Products.
  • Click on New Button, a new product form is opened. In that form select the product type as Item/Service.
    • Item- A Tangible item which has inventory transactions and On-hand inventory.
    • Service- an Intangible item which has no On-hand inventory.
    • Now select Product sub-type, (note- if you open new product form from ‘all products and product master’ then you will be displayed with two option product/product masters in this drop down menu)
    • Enter Product Number.
    • Press ok and the current form closes and a new line is created in the products list page.

Product/Product Master Creation Process:
  • To create product go to Product Information Management à Common Forms à Products à Products.
  • Click on New Button, a new product form is opened. In that form select the product type as Item/Service.
    • Item- A Tangible item which has inventory transactions and On-hand inventory.
    • Service- an Intangible item which has no On-hand inventory.
    • Now select Product sub-type, (note- if you open new product form from all products and product master  then you will be displayed with two option product/product masters in this drop down menu)
    • Enter Product Number and all the related fields.
    • In the product variants section, select product dimensions group and configuration technology.
    • Press ok and the current form closes and a new line is created in the products list page.


Assigning Dimensions Groups to a Product Master:
  • In the product list page, double click on the product.
  • In the product details form opened, on the top of the form you will find Dimension Group Button.
  • Click on Dimensions group Button will open a drop down menu.
  • In the drop down menu you find three fields
    • Product Dimension group
    • Storage Dimension group
    • Tracking Dimension group
    • Select the appropriate groups from these menus.
 
Note:
Please don’t get confused between a ‘Product’ and ‘Product Master’; they are two different product types in AX 2012.
We can assign Product ‘Dimension Group’ to ‘Product Master’ but we can’t assign ‘Dimension Group’ to ‘Product’. ‘Product’ is a unique item which doesn’t have any variants.
Creating Product Dimensions and creating dimension combinations:
  • In the product details form, in the product master field press product dimensions button.
  • In the Product dimensions form in the left pane, all the dimensions related to that product will be displayed.
  • Click on one dimension, the right pane will display the dimension already entered if any.
  • If you are entering dimensions for the first time, the right pane will be empty.
  • Now press new button, a new blank line is created. Enter the dimensions.
  • For example, if you select configuration in the left pane then enter the configuration dimension of the product in the right pane.
  • Similarly repeat the steps for all the product dimensions.
 
Product dimension combinations (Product Variants):
  • Once you create all the dimensions for a product, in ax 2009 we need to create item combinations.
  • Similarly in ax2012 we use Product Variants.
  • You can find product variants button in the product master section of the product master details form.
  • Please refer to the below screenshot
  • In the product variants form, you can create product dimension combinations using two methods,
    • By directly clicking on new button and selecting appropriate configurations. (OR)
    • By clicking on ‘Variant Suggestions’ will open a new form displaying all the possible combinations. Just check the select checkbox on the combinations you want and press OK.
Release product to legal entities:
  • Once you have created the product you need to release that product for use by your companies.
  • To release a product, go to that product in the product master form and on the top of the form in Product Authorization section press on ‘Release Product for Legal Entities’ button.
  • Release Products form is opened. Please see the screenshot for your reference.
 
  • In the left hand side of the form, press ‘select products’. In the right hand side, all the products will be displayed. Further right to that, you will find all the product variants.
  • Select the required products or product variants.
  • Now Press ‘Select Companies’ from left hand side pane.  All the companies in the ax will be displayed.
  • Now select the companies in which you want to use this product and after finishing press OK.
  • Now you have Released your Product for further use.
Assigning Item Model Group & Item Groups to a Product Master:
  • In the Released products form (go to product information management module a common forms a Released Products) select your product and click on ‘Edit’ button on top left.
  • In the Released product details form, in the General Fast Tab , you will find ‘Item Model Group’ Field
  • From the drop down menu, select an item model group.
  • In the same form , in ‘Manage costs’ tab posting, field you will find ‘Item Groups’ Field.
  • From the drop down menu select an Item Group.
  • Now the item or Product or Product master is ready for further transactions.

Friday 23 August 2013

Release products to the legal entities using X++ [Dynamics AX 2012]

In Microsoft Dynamics AX 2012, Microsoft has enhanced the item-product data management framework to provide flexibility and sustainability across the organization.In Microsoft Dynamics AX 2012, all product master data is shared across all companies, and the virtual table collection concept is no longer available for product master data management. The old item representation (InventTable) still exists[msdn]

I will be using 2 legal entities – CEU and newly created legal entity ‘CEE’
[If you want to create new legal entity - Organization administration >> setup >> Organization >> Legal entities >> New]
Let me show you the product master data [a particular product] which I am trying to release using code.
EcoResProductReleaseManagerBase class will help to release products to the legal entities. static method -releaseproduct will release products.

static void SST_ReleaseProducts(Args _args)
{
EcoResProduct ecoResProduct;
;

select firstOnly ecoResProduct where EcoResProduct.DisplayProductNumber == “1100″;
EcoResProductReleaseManagerBase::releaseProduct(ecoResProduct.RecId,
CompanyInfo::findDataArea(‘CEE’).RecId);
}
After running the above job, you will see that 1100 product number has been released to legal entity ‘CEE’ as shown below.


static void SST_ReleaseProducts_detailed(Args _args)
{

EcoResProduct ecoResProduct;
InventTable inventTable;
InventTableModule inventTableModule;
NumberSequenceTable numberSequenceTable;
ItemId itemId;
InventItemSetupSupplyType inventItemSetupSupplyType;
EcoResStorageDimensionGroupProduct ecoResStorageDimensionGroupProduct;
EcoResTrackingDimensionGroupProduct ecoResTrackingDimensionGroupProduct;
EcoResStorageDimensionGroupItem ecoResStorageDimensionGroupItem;
EcoResTrackingDimensionGroupItem ecoResTrackingDimensionGroupItem;
;
select firstOnly ecoResProduct where EcoResProduct.DisplayProductNumber == “1100″; /
changecompany (‘CEE’)
{
ttsBegin;
inventTable = null;
inventTableModule = null;
inventItemSetupSupplyType = null;
ecoResStorageDimensionGroupProduct = null;
ecoResTrackingDimensionGroupProduct = null;
ecoResStorageDimensionGroupItem = null;
ecoResTrackingDimensionGroupItem = null;
numberSequenceTable = InventParameters::numRefItemId().numberSequenceTable();
//get item id from:
//1. Product number if number seq for item ID is not set up or manual or return blank value
if (!numberSequenceTable.RecId || numberSequenceTable.Manual)
{
itemId = ecoResProduct.productNumber();
}
else //number sequence auto, get a number
{
itemId = NumberSeq::newGetNumFromId(numberSequenceTable.RecId).num();
}
inventTable.initValue();
inventTable.initFromEcoResProduct(ecoResProduct);
inventTable.ItemId = ItemId;
inventTable.NameAlias = ecoResProduct.SearchName;
inventTable.insert(true);
// Create inventTableModules
inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Invent;
inventTableModule.insert();
inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Purch;
inventTableModule.insert();
inventTableModule.initValue();
inventTableModule.ItemId = inventTable.ItemId;
inventTableModule.ModuleType = ModuleInventPurchSales::Sales;
inventTableModule.insert();
//Create inventItemLocation
InventItemLocation::createDefault(inventTable.ItemId);
// Creates a new item default order type for the product that is released.
inventItemSetupSupplyType.initValue();
inventItemSetupSupplyType.ItemId = inventTable.ItemId;
inventItemSetupSupplyType.ItemDataAreaId = inventTable.DataAreaId;
inventItemSetupSupplyType.insert();
//create relationship tables to dimension groups.
ecoResStorageDimensionGroupProduct = EcoResStorageDimensionGroupProduct::findByProduct(ecoResProduct.RecId);
ecoResTrackingDimensionGroupProduct = EcoResTrackingDimensionGroupProduct::findByProduct(ecoResProduct.RecId);
if (ecoResStorageDimensionGroupProduct.RecId)
{ // mandatory storage dimension group for the product
ecoResStorageDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResStorageDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResStorageDimensionGroupItem.StorageDimensionGroup = ecoResStorageDimensionGroupProduct.StorageDimensionGroup;
ecoResStorageDimensionGroupItem.insert();
}

if (ecoResTrackingDimensionGroupProduct.RecId)
{ // mandatory tracking dimension group for the product
ecoResTrackingDimensionGroupItem.ItemDataAreaId = inventTable.DataAreaId;
ecoResTrackingDimensionGroupItem.ItemId = inventTable.ItemId;
ecoResTrackingDimensionGroupItem.TrackingDimensionGroup = ecoResTrackingDimensionGroupProduct.TrackingDimensionGroup;
ecoResTrackingDimensionGroupItem.insert();
}
ttsCommit;
info(strfmt(“Product successfully released to ‘CEE’ legal entity”));
}
}
In Microsoft Dynamics AX 2012 inventory dimensions have been divided into the following three categories:
Product dimensions:These correspond to the old item dimensions.
Storage dimensions:These are Site, Warehouse, Location, and Pallet.
Tracking dimensions:These are Batch number and Serial number.

Hi,
In this post, I would like to share some Product information in Ax 2012 that will help to understand
 Inventory structure. In AX 2012 Inventory structure has been completely changed. So in brief
 we can understand the same as:


Understanding the Product structure:


Product type
  Item type - This option will be selected if the product is an inventoried product
       Service type - This option will be selected if the product is a non-inventoried product

Product sub type

                 Product master - Products of this sub-type must have a product dimension group that
         specifies the product dimensions that are active for the product (color, size, and configuration)
o    Configuration technology
§  Predefined variant - This type should be chosen if the product will not be
  configured, but simply rely on the user’s choice of Color, and/or Size, and/or
  Configuration for each transaction
§  Dimension-based configuration - This type should be chosen if the user will 
  build a configurable BOM that relies on configuration rules to build the
  Config ID and the BOM lines. (This technology may only be chosen if 
  Configuration is active on the Product dimension group selected for the
  product)
§  Rule-based configuration - This type should be chosen if the product will
 use Product builder
§  Constraint-based configuration - This type should be chosen if the product
 will use the new AX 2009 Constraint based product configuration method. 
(This technology may only be chosen if Configuration is active and is the lone 
Product dimension active for the Product dimension group selected for the
 product)

         Product - Products of this sub-type do NOT have any product dimensions, and therefore do
    not have a product dimension group
        Product variant - A large amount of information may be maintained at the Product master
          level, including, but not   limited to:
o    Product dimensions
o    Images
o    Product categories
o    Product attributes
o   Unit conversions
For Product master products, Product dimensions and Product variants are
      extremely important. Both may be managed from menu items in the ribbons
      section of the Products form:

Dimensions
                                   Product dimensions: Color, Size, Configuration
                       Storage dimensions: Site, Warehouse, Location, Pallet ID
                       Tracking dimensions: Batch number, Serial number

Release product
Once product variants have been created at the instance level, they must be released
 to individual companies before transactions may be performed in the respective 
company. Variants may be released from any of the Products forms (All, Distinct,
 Product masters), or from the Product variants form by clicking Release products in 
the ribbon section of the form. 

 Tech part (Data model)
AX 2012 Item AIF Web Service (InventItemService) 
Table Name
Table Description
EcoResProduct
The EcoResProduct table stores products and is the base table in the products hierarchy.
EcoResProductMaster
The EcoResProductMaster table stores product masters.
EcoResProductIdentifier
The EcoResProductIdentifier table contains a product identification that is available for users.
EcoResDistinctProduct
The EcoResDistinctProduct table stores products.
EcoResDistinctProductVariant
The EcoResDistinctProductVariant table stores product variants.
EcoResProductDimensionGroup
The EcoResProductDimensionGroup table contains information about a dimension group.
EcoResProductDimensionGroupProduct
The EcoResProductDimensionGroupProduct table stores information about relationships between products and dimension groups.
EcoResColor
The EcoResColor table stores color names.
EcoResSize
The EcoResSize table stores size names.
EcoResConfiguration
The EcoResConfiguration table stores configuration names.
EcoResProductMasterColor
The EcoResProductMasterColor table stores information about colors assigned to product masters.
EcoResProductMasterSize
The EcoResProductMasterSize table stores information about sizes that are assigned to product masters.
EcoResProductMasterConfiguration
The EcoResProductMasterConfiguration table stores information about configurations assigned to product masters.
EcoResProductVariantColor
The EcoResProductVariantColor table stores information about the colors that are assigned to product variants.
EcoResProductVariantSize
The EcoResProductVariantSize table stores information about the sizes that are assigned to product variants.
EcoResProductVariantConfiguration
The EcoResProductVariantConfiguration table stores information about the configurations that are assigned to product variants.
EcoResProductMasterDimensionValue
The EcoResProductMasterDimensionValue table is the base table in the product model dimension hierarchy.
EcoResProductVariantDimensionValue
The EcoResProductVariantDimensionValue table is the base table in the product variant dimension hierarchy.
EcoResProductDimensionAttribute
The EcoResProductDimensionAttribute table contains definitions of product dimension attributes (categories).
EcoResInstanceValue
The EcoResInstanceValue table contains the definitions of the instances of the components or products.
EcoResProductInstanceValue
The EcoResProductInstanceValue table contains definitions of values for the instances of attributes of a product.
InventTable
The InventTable table contains information about items.
InventTableModule
The InventTableModule table contains information about purchase, sales, and inventory specific settings for items.
InventItemLocation
The InventItemLocation table contains information about items and the related warehouse and counting settings. The settings can be made specific based on the items configuration and vary from warehouse to warehouse.
InventItemSalesSetup
The InventItemSalesSetup table contains the default settings for items, such as site and warehouse. The values are related to sales settings.
InventItemInventSetup
The InventItemInventSetup table contains the default settings for items, such as site and warehouse. The values are related to inventory settings.
InventItemPurchSetup
The InventItemPurchSetup table contains the default settings for items, such as site and warehouse. The values are related to purchase settings.
InventItemSetupSupplyType
The InventItemSetupSupplyType table contains information about the sourcing of items.
InventDim
The InventDim table contains values for inventory dimensions.
InventDimCombination
The InventDimCombination table contains variants of items. The variants are created as product variants that are based on product dimensions such as size, color, and configuration. These variants are replicated to the legal entity.