Showing posts with label Howto. Show all posts
Showing posts with label Howto. Show all posts

Tuesday, May 25, 2021

Set Financial Dimensions by X++ code in AX 2012/Setting one Dimension value in the combination

    /// <summary>
    /// replace specific financial dimension value in DefaultDimension based on the LedgerParameters setup
    /// </summary>
    /// <param name = "_defaultDimensionFrom">DefaultDimension recId the value should be taken from</param>
    /// <param name = "_defaultDimensionTo">DefaultDimension recId the value should be assigned to</param>
    /// <returns>returns new DefaultDimension recId if conditions are met</returns>
    public static DimensionDefault replaceDefaultDim(DimensionDefault _defaultDimensionFrom, DimensionDefault _defaultDimensionTo)
    {
        if(!_defaultDimensionFrom)
        {
            return _defaultDimensionTo;
        }

        LedgerParameters ledgerParameters = LedgerParameters::find();

        if (ledgerParameters.DepartmentSetFinancialDimension &&
            ledgerParameters.DepartmentDimensionAttribute)
        {
            DimensionAttribute                  dimAttr;
            DimensionAttributeValue             dimAttrValue;
            DimensionAttributeValueSetStorage   davss;

            davss = DimensionAttributeValueSetStorage::find(_defaultDimensionTo);

            dimAttr = DimensionAttribute::find(ledgerParameters.DepartmentDimensionAttribute);

            DimensionAttributeValueSetStorage dimStorage = DimensionAttributeValueSetStorage::find(_defaultDimensionFrom);
            DimensionValue dimValue = dimStorage.getDisplayValueByDimensionAttribute(dimAttr.RecId);

            dimAttrValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttr, dimValue);

            if(dimAttrValue && !davss.containsDimensionAttributeValue(dimAttrValue.RecId))
            {
                davss.addItem(dimAttrValue);

                return davss.save();
            }
        }

        return _defaultDimensionTo;
    }

Monday, April 26, 2021

UserConnection in D365fo

Its used when we need to commit our transaction wehen standared code doesn't Commit.
example :SalesQuotationEditLinesForm_Sales_Send > checkSales() , COC and try to write 
custom insert or update operation here while validation is failed our transactions doesn't commit

static void KlForRecordInserted(Args _args)
{
    UserConnection userConnection;
    CustTable custTable;
    ;
   
    ttsbegin;
   
    userConnection = new userConnection();
   
    custTable.clear();
    custTable.initValue();
    custTable.AccountNum = "000020";
    custTable.Name = "My Test Customer";
    custTable.setConnection(userConnection); // set userconnection
    custTable.insert();
   
    throw error("An error that causes a rollback");
    ttscommit;
}

Thursday, April 22, 2021

How to get the number of elements in the list in AX

{ 
    List il = new List(Types::Integer); 
 
    il.addStart(1); 
    il.addStart(2); 
    il.addStart(3); 
    if (il.elements() != 3) 
    { 
        print "Something is wrong..."; 
    } 
}

Tuesday, April 13, 2021

How to create a collapsible section in Blogger

Add CSS

Add a unique name for each new post eg: collapsible1 or collapsible2 etc
add at the start of the HTML code after <HTML> tag
<style>
.collapsible {
  background-color: #777;
  color: white;
  cursor: pointer;
  padding: 18px;
  border: none;
  text-align: left;
  outline: none;
  font-size: 15px;
}

.active, .collapsible:hover {
  background-color: #555;
}

.content1 {
  padding: 0 18px;
  display: none;
  overflow: hidden;
  background-color: #f1f1f1;
}
</style>

Apply CSS to div and Paragragh

add these classes in the paragrah and the div at the start of the tag
<p title="UIBuilder" class="collapsible">UIBuilder class</p>
<div class="content1"></div>

Javascript

add at the end of the HTML code before </HTML> tag
<script>
var coll = document.getElementsByClassName("collapsible");
var i;

for (i = 0; i < coll.length; i++) {
  coll[i].addEventListener("click", function() {
    this.classList.toggle("active");
    var content = this.nextElementSibling;
    if (content.style.display === "block") {
      content.style.display = "none";
    } else {
      content.style.display = "block";
    }
  });
}
</script>

Table browser URL in D365FO

Critical Thinking icon icon by Icons8