Tuesday 20 December 2016

Computed Column in Views

Sample Method 1:
public server static str getCategory()
{
    str viewName = tableStr(SAED_Workers_Dimension);
    str sql;
    // this is the data source's name,
    // which may not be the same as the table name
    str SitDirPerson_ds = identifierStr(SitDirPerson_1);
     str HcmJob_ds = identifierStr(HcmJob_1);
    str NationalityField = fieldStr(SitDirPerson, Nationality);//Table name
    str JobField      = fieldStr(HcmJob, JobId);//Table name
    // to contain the actual SQL column name
    str Nationality;
    str Job;
    // the following will return a string similar to T1.VehicleId
    Nationality = SysComputedColumn::returnField(viewName,
                                               SitDirPerson_ds,
                                               NationalityField);
    Job      = SysComputedColumn::returnField(viewName,
                                               HcmJob_ds,
                                               JobField);
    sql = Nationality + "+ '' + " + Job;
    return sql;
}

Sample Method2:

public server static str getDeptDimension()
{
   str viewName = tableStr(SAED_Workers_Dimension);
    str sql;
    // this is the data source's name,
    // which may not be the same as the table name
    str datasourceName = identifierStr(HcmPositionDefaultDimension_1); //Datasource name
    str datasourceName1 = identifierStr(SitDirPerson_1); //Datasource name
    str DefaultDimensionField = fieldStr(HcmPositionDefaultDimension, DefaultDimension);
    str dataAreaFIeld  = fieldStr(HcmWorker, DataAreaId);
    str partitionField = fieldStr(HcmWorker, Partition);
    // to contain the actual SQL column name
    str DefaultDimensionId;
    str dataAreaId;

    str partition;
    // the following will return a string similar to T1.VehicleId
    dataAreaId = SysComputedColumn::returnField(viewName,
                                               datasourceName1,
                                               dataAreaFIeld);
    partition = SysComputedColumn::returnField(viewName,
                                               datasourceName1,
                                               partitionField);
    DefaultDimensionId = SysComputedColumn::returnField(viewName,
                                               datasourceName,
                                               DefaultDimensionField);

    sql  = "SELECT DisplayValue FROM DefaultDimensionView LVS \n";
    sql += "    WHERE LVS.Name= 'Department' and LVS.DefaultDimension  = " + DefaultDimensionId  + "\n";
    //sql += "      AND LVS.DataAreaId = " + dataAreaId + "\n";
    sql += "      AND LVS.Partition  = " + partition + "\n";

    return sql;
}

Thursday 15 December 2016

SSRS – No connection could be made

  1.  Check in C:\Program Files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting   Services\ReportServer\bin\Microsoft.Dynamics.AX.ReportConfiguration.axc.
  2.  Edit the file and change the port.
  3. If the file is not there, open AX client configuration, configure your instance with same port and export this configuration file in the above path with same name  Microsoft.Dynamics.AX.ReportConfiguration.axc
  4. In case any permission issue or Company parameter expected error, go to  C:\Program Files\Microsoft SQL Server\MSRS12.MSSQLSERVER\Reporting   Services\ReportServer\rssrvpolicy.config , edit the file in code group , change the permission set name to Fullcontrol.

Thanks