Hide Export file format : SSRS Report Viewer using X++

Sample Code to hide the Export option from SSRS report viewer using x++

IMG1

 

STEP 1: First We need to add the reference “Microsoft.ReportViewer.WinForms” in AOT

reference

STEP 2:  Add the below code into the Form “SRSReportViewer’

FormCode.PNG

 

public void hideExportButton()public void hideExportButton()

{

System.Windows.Controls.UIElementCollection children;    Microsoft.Reporting.WinForms.ReportViewer reportViewer;

children = _axreportViewer_control.get_Children();    reportViewer = children.get_Item(0);
reportViewer.set_ShowExportButton(false);

}

 

STEP 3: Now call this code into the run method of this form with the desired report name

Code.png

 

Result :

 

Result.PNG

 

 

 

 

 

 

Advertisements

Emploee Lookup – Legal entity specific – Active Emploee

Sample Code to generate Employee Lookup . Which contains Active employee, Legal entity specific and here i have an extra filter to exclude workers starting from 00.

You can also use the same code to get the Terminated employee just by Slight change in the query .

public void lookup()
{
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRange;
SysTableLookup sysTableLookup;

QueryBuildDataSource queryBuildDataSource1;
RecId _LegalEntity;
;

//Create an instance of SysTableLookup with the form control passed in
sysTableLookup = SysTableLookup::newParameters(tablenum(HcmWorker), this);

//Add the fields to be shown in the lookup form
sysTableLookup.addLookupfield(fieldnum(HcmWorker, PersonnelNumber), false);
sysTableLookup.addLookupMethod(‘Name’);

//create the query datasource
queryBuildDataSource = query.addDataSource(tablenum(HcmWorker));
queryBuildDataSource.addRange(fieldNum(HcmWorker, PersonnelNumber))
.value(SysQuery::valueLikeAfter(‘!00’));

queryBuildDataSource1 = queryBuildDataSource.addDataSource(tableNum(HcmEmployment));
queryBuildDataSource1.joinMode(JoinMode::ExistsJoin);
queryBuildDataSource1.relations(true);
queryBuildDataSource1.addRange(fieldNum(HcmEmployment, LegalEntity))
.value(SysQuery::value(CompanyInfo::findDataArea(SelectableDataArea.valueStr()).recId));

//add the query to the lookup form
sysTableLookup.parmQuery(query);

// Perform lookup
sysTableLookup.performFormLookup();

}

Run RDP based report from Code & passing parameter using Data contract

Bsic Code to run RDP based report using x++ and passing parameters to data contract.

SrsReportRunController controller = new SrsReportRunController();
VendSOAReportTmpContract rdpContract = new VendSOAReportTmpContract ();
SRSPrintDestinationSettings settings;

 

controller.parmReportName(ssrsReportStr(VendSOATmpReport,PrecisionDesign));

controller.parmShowDialog(false);
rdpContract.parmVendAccount(VendPurchOrderJour.OrderAccount);
controller.parmReportContract().parmRdpContract(rdpContract);
controller.startOperation();

Step name of Workflow

Below is the reference sample code to get the workflow step name.

public display str 25 stepName(PurchReqTable _purchReqTable)
{
container con;
PurchReqTable purchReqTable;
PurchReqTableHistory purchReqTableHistory;
WorkflowTrackingStatusTable workflowTrackingStatus;
WorkflowTrackingTable workflowTracking;
utcdatetime validDate = DateTimeUtil::utcNow();
WorkflowStepName stepName;
TransDate stepSinceDate;
PurchReqRequisitionStatus status;
TransDate statusSinceDate;
RefRecId workflowTrackingStatusRecId;
RefRecId workflowStepRecId;
UserInfo userInfo;
WorkflowTrackingTable workflowTrackingLocal,workflowTrackingLocal2,workflowTrackingLocal3;
WorkflowStepTable workflowstepTable;
RefRecId _purchReqTableRecId = _purchReqTable.RecId;

/* Get the current status */
select firstonly validTimeState(validDate)
CreatedDateTime, RequisitionStatus from purchReqTable
where purchReqTable.RecId == _purchReqTableRecId

outer join CreatedDateTime from purchReqTableHistory
where purchReqTableHistory.PurchReqTable == purchReqTable.RecId

outer join RecId from workflowTrackingStatus
order by workflowTrackingStatus.CreatedDateTime desc
where workflowTrackingStatus.ContextTableId == purchReqTable.TableId &&
workflowTrackingStatus.ContextRecId == purchReqTable.RecId;

/* line-item subworkflow */
select firstonly RecId, Name, CreatedDateTime, TrackingContext, TrackingType,WorkflowElementTable,WorkflowTrackingStatusTable,WorkflowStepTable from workflowTracking
order by workflowTracking.CreatedDateTime desc
where workflowTracking.WorkflowTrackingStatusTable == workflowTrackingStatus.RecId;
if (workflowTracking.TrackingContext != WorkflowTrackingContext::LineItemElement ||
workflowTracking.TrackingType != WorkflowTrackingType::Creation)
{
/* Current step */
select firstonly RecId, Name, CreatedDateTime, TrackingContext, TrackingType,WorkflowElementTable,WorkflowTrackingStatusTable,WorkflowStepTable from workflowTracking
order by workflowTracking.CreatedDateTime desc
where workflowTracking.WorkflowTrackingStatusTable == workflowTrackingStatus.RecId &&
workflowTracking.TrackingContext == WorkflowTrackingContext::Step &&
workflowTracking.TrackingType == WorkflowTrackingType::Creation;
}

if (purchReqTable != null)
{
status = purchReqTable.RequisitionStatus;
userInfo = xUserInfo::find(false, curUserId());

if (purchReqTableHistory != null)
{
statusSinceDate = DateTimeUtil::date(DateTimeUtil::applyTimeZoneOffset(purchReqTableHistory.CreatedDateTime, userInfo.PreferredTimeZone));
}
else
{
statusSinceDate = DateTimeUtil::date(DateTimeUtil::applyTimeZoneOffset(purchReqTable.CreatedDateTime, userInfo.PreferredTimeZone));
}

if (workflowTracking != null)
{
stepName = workflowTracking.Name;
stepSinceDate = DateTimeUtil::date(workflowTracking.CreatedDateTime);
workflowTrackingStatusRecId = workflowTrackingStatus.RecId;
workflowStepRecId = workflowTracking.WorkflowStepTable;
}
select firstOnly workflowTrackingLocal
where workflowTrackingLocal.TrackingType == WorkflowTrackingType::Return &&
workflowTrackingLocal.WorkflowElementTable == workflowTracking.WorkflowElementTable &&

workflowTrackingLocal.WorkflowTrackingStatusTable == workflowTracking.WorkflowTrackingStatusTable &&
workflowTrackingLocal.RecId > workflowTracking.RecId;

if (workflowTrackingLocal)
{
select firstOnly workflowTrackingLocal2
where workflowTrackingLocal2.TrackingType == WorkflowTrackingType::Creation &&
workflowTrackingLocal2.TrackingContext == WorkflowTrackingContext::Step &&
workflowTrackingLocal2.WorkflowElementTable == workflowTrackingLocal.WorkflowElementTable &&
workflowTrackingLocal2.WorkflowStepTable == workflowTracking.WorkflowStepTable &&
workflowTrackingLocal2.WorkflowTrackingStatusTable == workflowTrackingLocal.WorkflowTrackingStatusTable &&
workflowTrackingLocal2.RecId > workflowTrackingLocal.RecId;
}
if (!workflowTrackingLocal2)
{

 

select firstOnly workflowTrackingLocal2
where workflowTrackingLocal2.TrackingType == WorkflowTrackingType::Creation &&
workflowTrackingLocal2.TrackingContext == WorkflowTrackingContext::Task &&
workflowTrackingLocal2.WorkflowElementTable == workflowTrackingLocal.WorkflowElementTable &&
workflowTrackingLocal2.WorkflowStepTable == workflowTracking.WorkflowStepTable &&
workflowTrackingLocal2.WorkflowTrackingStatusTable == workflowTrackingLocal.WorkflowTrackingStatusTable &&
workflowTrackingLocal2.RecId > workflowTrackingLocal.RecId;

}

if (workflowTrackingLocal2 != null)
{

workflowstepTable = workflowstepTable::findRecId(workflowTrackingLocal2.WorkflowStepTable);
stepName = workflowstepTable.Name;
stepSinceDate = DateTimeUtil::date(workflowTrackingLocal2.CreatedDateTime);
workflowTrackingStatusRecId = workflowTrackingLocal2.WorkflowTrackingStatusTable;
workflowStepRecId = workflowTrackingLocal2.WorkflowStepTable;
}

}

return stepName;
}