Thursday, 30 June 2016

SSRS error : Domain role with multiplicity 0..1 or 1 can hold at most 1 link..

We often get the following error when we try to duplicate any SSRS report in viusal studio or  we do any change in report parameters..



To resolve this error, we just need to reset report datasets as it is when a new dataset is created :
  • Set Data Source Type property to Query and remove anything which is already existed in Query property. (i.e Fig 1.0)


Fig 1.0 (Resetting dataset properties  )


  • Save and rebuild the report project, the above mentioned error would be resolved by now.
  • Now set the dataset properties as they were before and it will work like a charm.

Wednesday, 29 June 2016

Joining Datasources through Code using QueryBuildDataSource


Sometimes we need to add two or more datasources in our code. We use QueryBuildDatasource class for this purpose. Below is a sample job which is creating a query in code using Query class and joining two datasources by using QueryBuildDatasource class. And off course if we know how to add second datasource to first datasource, you could add more datasources using the same technique..  

static void JoiningTwoDatasourcesSample(Args _args)
{
    Query                       query;
    QueryBuildDatasource        queryBuildDatasource;
    query = new Query();

    //Adding table as the first datasource in query..
    queryBuildDatasource = query.addDataSource(tableNum(PurchTable));

    //adding table into the datasource of previously created datasource..
    queryBuildDatasource = queryBuildDatasource.addDataSource(tableNum(PurchLine));

    //Specifing which type of join you want to use in between both of the above datasources..
    queryBuildDatasource.joinMode(JoinMode::InnerJoin);

    //whether we want to use auto relations between table (i.e. True) or to create link by your own as mentioned below (i.e. False)
    queryBuildDatasource.relations(false);

    //Adding link to both table by specifying the fields of both tables which links them together..
    queryBuildDatasource.addLink(fieldNum(PurchTable, PurchId), fieldNum(PurchLine, PurchId));

    info(query.xml());

}