Number seq in D365

HI,

  1. Create new EDT
  2. Add EDT to new table and write below method at table level.
    1. static NumberSequenceReference numRefMROBulkTransferNumber()
      {
      return NumberSeqReference::findReference(extendedTypeNum(MROBulkTransferNumber));
      }
  3. write new class to extend existing module class
    1. [ExtensionOf(classStr(NumberSeqModuleMRO))]
      final class NumberSeqModuleMRO_Extension
      {

      protected void loadModule()
      {
      NumberSeqDatatype datatype = NumberSeqDatatype::construct();

      next loadModule(); // Execute the augmented original class method

      datatype.parmDatatypeId(extendedtypenum(MROBulkTransferNumber));
      datatype.parmReferenceHelp(literalstr(“Number for Bulk transfer”));
      datatype.parmWizardIsManual(NoYes::No);
      datatype.parmWizardIsChangeDownAllowed(NoYes::No);
      datatype.parmWizardIsChangeUpAllowed(NoYes::No);
      datatype.parmWizardLowest(1);
      datatype.parmWizardHighest(99999999);
      datatype.parmSortField(82);
      datatype.addParameterType(NumberSeqParameterType::DataArea, true, false);
      this.create(datatype);
      }

      }

  4. Create new Runnable class(Job)
    1. class RunnableClass_numberSeq
      {
      /// <summary>
      /// Runs the class with the specified arguments.
      /// </summary>
      /// <param name = “_args”>The specified arguments.</param>
      public static void main(Args _args)
      {

      NumberSeqModuleMRO numberSeqMod = new NumberSeqModuleMRO();
      numberSeqMod.load();
      }

      }

  5. To go Organization Administration -> CommonForms -> Numbersequences -> Numbersequences -> Generate -> run the wizard.
  6. Navigate to module(MRO in my case): Setup -> Project management parameters form -> Num Seq.  You will find your new numberSeq
Advertisements

Using UIBuilder in SSRS contract class

Hi, Below sample code used to get lookups.

In this scenario, i need to get itemid lookup based on Invoice id selected.

UIBuilder class

  1. public class testUIBuilder extends SysOperationAutomaticUIBuilder
    {
    testContract contract;
    DialogField dialogInvoiceId;
    DialogField dialogItemId;
    }
  2. public void build()
    {
    Dialog dialogLocal = this.dialog();
    contract = this.dataContractObject();
    this.addDialogField(methodStr(testContract,parmInvoiceId), contract);
    this.addDialogField(methodStr(testContract,parmItemId), contract);
    }
  3. public void getFromDialog()
    {
    contract = this.dataContractObject();
    super();
    }
  4. public void initializeFields()
    {
    contract = this.dataContractObject();
    }
  5. public void lookupItem(FormStringControl _control)
    {
    Query query = new Query();
    QueryBuildDataSource queryBuildDataSource, queryBuildDataSource1;
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(CustInvoiceTrans), _control);
    ;

    sysTableLookup.addLookupfield(fieldnum(CustInvoiceTrans, ItemId),true);

     

    queryBuildDataSource = query.addDataSource(tablenum(CustInvoiceTrans));

    queryBuildDataSource1 = queryBuildDataSource.addDataSource(tablenum(CustInvoiceTrans));

    queryBuildDataSource1.addRange(fieldnum(CustInvoiceTrans, InvoiceId)).value(queryvalue(dialogInvoiceId.value()));

    sysTableLookup.parmQuery(query);

    sysTableLookup.performFormLookup();
    }

  6. public void postBuild()
    {
    ;
    super();
    dialogInvoiceId = this.bindInfo().getDialogField(
    this.dataContractObject(),
    methodStr(testContract,parmInvoiceId));

    dialogItemId = this.bindInfo().getDialogField(
    this.dataContractObject(),
    methodStr(testContract,parmItemId));
    // register override method for lookup customer
    dialogItemId.registerOverrideMethod(methodStr(FormStringControl, lookup), methodStr(testUIBuilder,lookupItem),this);

    }

  7. public void postRun()
    {
    Dialog dialogLocal = this.dialog();
    super();
    // This method should be called in order to handle events on dialogs.
    dialogLocal.dialogForm().formRun().controlMethodOverload(false);
    }

Contract class

  1. [
    DataContractAttribute,
    SysOperationContractProcessingAttribute(classStr(testUIBuilder))]
    public class testContract implements SysOperationValidatable
    {
    InvoiceId invoiceId;
    ItemId itemId;
    }
  2. [
    DataMemberAttribute(‘InvoiceId’),
    SysOperationDisplayOrderAttribute(‘1’)
    ]
    public InvoiceId parmInvoiceId(InvoiceId _invoiceId = invoiceId)
    {
    invoiceId = _invoiceId;
    return invoiceId;
    }
  3. [
    DataMemberAttribute(‘ItemId’),
    SysOperationDisplayOrderAttribute(‘2’)
    ]
    public ItemId parmItemId(ItemId _itemId = itemId)
    {
    itemId = _itemId;
    return itemId;
    }

 

Merging two queries ranges

HI Below sample code used to merge 2 queries ranges.

private void merge(Query _queryPRA, Query _this)
{
QueryBuildDataSource rpa, pfr;
int rpaRanges,i, rpaFilters;
QueryBuildRange range;
QueryFilter queryFilter;

//Fetch ranges from Query
rpaRanges =_queryPRA.dataSourceTable(tableNum(SalesTable)).rangeCount();
for (i=1 ; i<=rpaRanges; i++)
{
range = _queryPRA.dataSourceTable(tableNum(SalesTable)).range(i);

_this.dataSourceTable(tablenum(SalesTable)).addRange(_queryPRA.dataSourceTable(tableNum(SalesTable)).range(i).field()).value(queryValue(range.value()));
}

//fetch user filters from Dialog
rpaFilters = _queryPRA.queryFilterCount();

for (i=1 ; i<=rpaFilters; i++)
{
queryFilter = _queryPRA.queryFilter(i);

_this.dataSourceTable(tablenum(SalesTable)).addRange(fieldName2id(tableNum(SalesTable), _queryPRA.queryFilter(i).field())).value(queryValue(queryFilter.value()));
}
}

Report printing Extra page

Hi, If report printing extra page please check below logic.

Body Width <= Page Width – (Left Margin + Right Margin)

Horizontal usable area:

X = Page.Width – (Left Margin + Right Margin + Column Spacing)

Vertical usable area:

Y = Page.Height – (Top Margin + Bottom Margin + Header Height + Footer Height)

Any time objects on your report (including the Body itself) extend past the usable area either because they are defined like that or because they grow at runtime, the physical page renderers have no choice but to break onto a new page.

SQL in X++, range in where clause

Below case is when ‘AccessFeedsFilter’ has value it should fetch that reocrds only if its empty: it should fetch all

 

while select SKUNumber, ItemId, inventDimId,LifeCycleStatusFlag,ItemName, InboundDepth, InboundHeight, InboundWeight, InboundWidth,
OutboundDepth, OutboundHeight, OutboundWeight, OutboundWidth, ActualDepth, ActualHeight, ActualWeight, ActualWidth, RetailVariantId, Description, BasePrice
from productsAndVariants
where (productsAndVariants.LifeCycleStatusFlag == ogoParameters.AccessFeedsFilter && ogoParameters.AccessFeedsFilter != “”) || (ogoParameters.AccessFeedsFilter == “” && true)

Split text multiple lines in Email body

HI, Below smaple code used to show splited text in email body.

{

SysMailer mailer;
SysEmailParameters parameters;
InteropPermission permission = new InteropPermission(InteropKind::ComInterop);
OWIStoreTable OWIStoreTable;
Notes bodymsg, bodymsghtml;
ListIterator iterator;
List strlist=new List(Types::String);
;
permission.assert();
mailer = new SysMailer();
parameters = SysEmailParameters::find();

if (parameters.SMTPRelayServerName)
{
mailer.SMTPRelayServer(parameters.SMTPRelayServerName,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}
else
{
mailer.SMTPRelayServer(parameters.SMTPServerIPAddress,
parameters.SMTPPortNumber,
parameters.SMTPUserName,
SysEmailParameters::password(),
parameters.NTLM);
}

mailer.fromAddress(‘test@AX.com’);
mailer.tos().appendAddress(‘AAA@gmail.com’);
mailer.subject(‘System Test’);

strlist =strSplit(‘AAA  BBB’,”\n”);

iterator = new ListIterator(strlist);

while(iterator.more())
{
bodymsg += strFmt(“%1<br>”,iterator.value());
iterator.next();
}

bodymsg = strReplace(bodymsg,’\n’,'<br>’);
bodymsg =bodymsg + “\n” + strFmt(“Last order %2 received for this webtore on: %1”, _lastSalesOrder.createdDateTime);

bodymsghtml= strFmtLB(bodymsg);

mailer.htmlBody(bodymsghtml);

mailer.sendMail();
}

Email sending using file template

HI, below sample code used to send email using Email tempalte formate in multiple lines and header formate.

static void sendMail(Email _defEmail, SysEmailId _emailTemplate, PurchTable PurchTable)
{
SysEmailParameters parameters = SysEmailParameters::find();
SMTPRelayServerName relayServer;
SMTPPortNumber portNumber;
SMTPUserName userName;
SMTPPassword password;
Str1260 subject;
Notes msgbody ;
InteropPermission interopPermission;
SysMailer mailer;
System.Exception e;

SysEmailTable table;
SysEmailMessageTable message;

str newMessageBody;

;

if(_defEmail)
{
if (parameters.SMTPRelayServerName)
relayServer = parameters.SMTPRelayServerName;
else
relayServer = parameters.SMTPServerIPAddress;

portNumber = parameters.SMTPPortNumber;
userName = parameters.SMTPUserName;
password = SysEmailParameters::password();

table = SysEmailTable::find(_emailTemplate);
message = SysEmailMessageTable::find(table.EmailId, table.DefaultLanguage);
if (message)
{
newMessageBody = VendorSendEmail::renderLetter(message,PurchTable);
}
subject = message.Subject;
msgbody = newMessageBody;

CodeAccessPermission::revertAssert();

try
{
interopPermission = new InteropPermission(InteropKind::ComInterop);
interopPermission.assert();
mailer = new SysMailer();
mailer.SMTPRelayServer(relayServer,portNumber,userName,password, parameters.NTLM);
mailer.fromAddress(SysUserInfo::find().Email);
mailer.tos().appendAddress(_defEmail);
mailer.subject(subject);
mailer.htmlBody(msgbody);
mailer.sendMail();
CodeAccessPermission::revertAssert();
info(“@CIT957”);
}
catch (Exception::CLRError)
{
e = ClrInterop::getLastException();

while (e)
{
info(e.get_Message());
e = e.get_InnerException();
}
CodeAccessPermission::revertAssert();
info (“error”);
}
}
else
error(“done”);

}