How to Add Recent Posts in Blogger

· 0 Comments

In any blog, recent posts and popular posts helps the readers to access the recent posts and popular psots easily, which will increase the user engangement in a blog, in this article we will explain you the general code for listing the recent pots in any blogger websites.

for this,

We need to add HTML or JavaScript code to your Blogger blog, you can use the built-in "HTML/JavaScript" gadget. Here's a step-by-step guide:

  1. Log in to your Blogger Account:
  2. Go to Blogger and sign in with your Google account.
  3. Access the Layout Section:
  4. In your Blogger dashboard, go to "Layout" in the left sidebar.
  5. Add a Gadget:

Find the section of your blog where you want to add the HTML or JavaScript code.

  1. Click on the "+ Add a Gadget" link within that section.
  2. Choose the HTML/JavaScript Gadget:

In the "Add a Gadget" window, find and click on the "HTML/JavaScript" gadget. This gadget allows you to add custom HTML or JavaScript code.

Add your HTML or JavaScript Code:

...

<div class="recentpoststyle">
<script type="text/javascript">
function showlatestposts(e) {
    for (var t = 0; t < posts_no; t++) {
        var r, s = e.feed.entry[t],
            n = s.title.$t;
        if (t == e.feed.entry.length) break;
        for (var a = 0; a < s.link.length; a++)
            if ("alternate" == s.link[a].rel) {
                r = s.link[a].href;
                break
            }
        n = n.link(r);
        var i = "... read more";
        i = i.link(r);
        var l = s.published.$t,
            o = l.substring(0, 4),
            u = l.substring(5, 7),
            c = l.substring(8, 10),
            m = new Array;
        if (m[1] = "Jan", m[2] = "Feb", m[3] = "Mar", m[4] = "Apr", m[5] = "May", m[6] = "Jun", m[7] = "Jul", m[8] = "Aug", m[9] = "Sep", m[10] = "Oct", m[11] = "Nov", m[12] = "Dec", "content" in s) var d = s.content.$t;
        else if ("summary" in s) var d = s.summary.$t;
        else var d = "";
        var v = /<\S[^>]*>/g;
        if (d = d.replace(v, ""), 1 == posts_date && document.write('<div class="post-date">' + m[parseInt(u, 10)] + " " + c + " " + o + "</div>"), document.write('<li class="recent-post-title">'), document.write(n), document.write('</li><div class="recent-post-summ">'), 1 == post_summary)
            if (d.length < summary_chars) document.write(d);
            else {
                d = d.substring(0, summary_chars);
                var f = d.lastIndexOf(" ");
                d = d.substring(0, f), document.write(d + " " )
            }
        document.write("</div>")
    }
}

</script>

<script type="text/javascript">
var posts_no = 5;
var posts_date = true;
var post_summary = true;
var summary_chars = 80;
</script>
<script src="/feeds/posts/default?orderby=published&amp;alt=json-in-script&amp;callback=showlatestposts">
</script>

<!-- css-->

<style type="text/css">
.recentpoststyle {
    list-style-type: none;
}
.recentpoststyle a {
    text-decoration: none;
    color: #49A8D1;
}
.recentpoststyle a:hover {
    color: #000;
}
.recentpoststyle li:before {
    float: left;
    z-index: 1;
    position: relative;
    font-size: 15px;
    font-weight: bold;
    color: #fff;
    background: #69B7E2;
    margin: 13px 5px 0px -6px;
    line-height: 30px;
    width: 30px;
    height: 30px;
    text-align: center;
    -webkit-border-radius: 50%;
    -moz-border-radius: 50%;
    border-radius: 50%;
}
li.recent-post-title {
    margin: 7px 0;
    padding: 0;
}
.recent-post-title a {
    color: black;
    text-decoration: none;
    font-weight:bold;
    font-family: 'Poppins', sans-serif;
    font-size: 14px;
}
.post-date {
    font-size: 11px;
    color: #999;
    margin:0;
}
.recent-post-summ {
    color: #777;
    padding: 0 0 15px;
    margin-bottom: 15px;
    font: 13px Verdana,Arial,Helvetica,sans-serif;
    border-bottom: 1px solid #ececec;
}
</style></div>

...

In the configuration window for the "HTML/JavaScript" gadget, paste your HTML or JavaScript code into the content box.

Save Changes:

Click on the "Save" or "Save arrangement" button to apply the changes.

Preview Your Blog:

Preview your blog to make sure the HTML or JavaScript content appears as expected.

Adjust Placement (if needed):

If you want to change the position of the HTML/JavaScript gadget, you can go back to the "Layout" section and drag the gadget to the desired location.

Remember to save your changes after adjusting the layout.

Please note that when adding JavaScript code, you need to ensure it complies with Blogger's policies. Some JavaScript code may be restricted for security reasons.

Keep in mind that the appearance and navigation in Blogger might change over time, so the steps provided here are based on the information available up to my last training cut-off in January 2022. If there have been any changes to the Blogger interface after that date, you might need to adapt the instructions accordingly.

How to Add Floating Sidebar Ads in Blogger

· 0 Comments

To add floating sidebar adsense ads in blogger of the screen on your Blogger website, you can use a combination of HTML, CSS, and JavaScript. Here's a step-by-step guide:

  1. Log in to your Blogger Account:
  2. Go to Blogger and log in to your account.
  3. Access Theme Editor:
  4. In your Blogger dashboard, navigate to the blog you want to edit.
  5. Click on "Theme" in the left-hand menu.
  6. Edit HTML:
  7. Click on the "Edit HTML" button.

Backup your Template:

Before making any changes, it's a good practice to make a backup of your template. Click on the "Download Theme" button to save a copy of your existing template.

...

<b:if cond='data:blog.isMobileRequest == &quot;false&quot;'>    
<b:if cond='data:blog.pageType == &quot;item&quot;'>
<style scoped='' type='text/css'>
.fixed-leftSd,.fixed-rightSd{position:fixed;top:-15px;width:120px;height:600px; margin: 15px; z-index:9999;transform:translateZ(0)}
.fixed-leftSd{left:-15px;}
.fixed-rightSd{right:35px;}
.close-fixedSd{position:absolute;width:160px;height:21px;line-height:15px;font-size:11px;font-weight:400;top:-20px;left:0;text-align:center;background:#e0e0e0;color:#666;padding:5px 0;cursor:pointer}
@media screen and (max-width:1300px){.fixed-leftSd,.fixed-rightSd{display:none;visibility:hidden;}}
</style>

<div class='fixed-leftSd'>

<div aria-label='Close Ads' class='close-fixedSd' onclick='this.parentElement.style.display=&quot;none&quot;' role='button' tabindex='0'> 
<b>CLOSE ADS</b> 
</div>

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="YOUR-AD-CLIENT-ID"
         data-ad-slot="YOUR-AD-SLOT-ID"
         data-ad-format="auto"></ins>
    <script>
         (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

</div>
  
 

<div class='fixed-rightSd'>

<div aria-label='Close Ads' class='close-fixedSd' onclick='this.parentElement.style.display=&quot;none&quot;' role='button' tabindex='0'> 
<b>CLOSE ADS</b> 
</div>

<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="YOUR-AD-CLIENT-ID"
         data-ad-slot="YOUR-AD-SLOT-ID"
         data-ad-format="auto"></ins>
    <script>
         (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

</div>

</b:if>
</b:if>

...

Replace "YOUR-AD-CLIENT-ID" and "YOUR-AD-SLOT-ID" with your AdSense ad client ID and ad slot ID.

Save Theme:

Click on the "Save theme" button to save your changes.
Preview and Adjust:

Preview your blog to see if the floating AdSense ad is displaying correctly. Adjust the CSS code as needed to fit your design.
Remember to comply with AdSense policies, and ensure that the ad placement adheres to Google's guidelines to prevent any issues with your AdSense account.

Blogger : How to add Floating AdSense Ad at Bottom Screen

· 0 Comments

To add a floating AdSense ad at the bottom of the screen on your Blogger website, you can use a combination of HTML, CSS, and JavaScript. Here's a step-by-step guide:

  1. Log in to your Blogger Account:
  2. Go to Blogger and log in to your account.
  3. Access Theme Editor:
  4. In your Blogger dashboard, navigate to the blog you want to edit.
  5. Click on "Theme" in the left-hand menu.
  6. Edit HTML:
  7. Click on the "Edit HTML" button.

Backup your Template:

Before making any changes, it's a good practice to make a backup of your template. Click on the "Download Theme" button to save a copy of your existing template.

Add the following CSS code just before the </b:skin> tag:

Add CSS for the Floating Ad:

...

   .stky-ads {
    position: fixed;
    bottom: -10px;
    left: 0;
    width: 100%;
    min-height: 30px;
    max-height: 93px;
    padding: 5px 5px;
    box-shadow: 0 -6px 18px 0 rgba(9, 32, 76, .1);
    -webkit-transition: all .1s ease-in;
    transition: all .1s ease-in;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    z-index: 20;
}

.stky-ads-close {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px 0 0;
    position: absolute;
    right: 0;
    top: -30px;
    background-color: #fefefe;
    box-shadow: 0 -6px 18px 0 rgba(9, 32, 76, .08);
    cursor: pointer;
}

.stky-ads .stky-ads-close svg {
    width: 22px;
    height: 22px;
    fill: #000;
}

.stky-ads .stky-ads-content {
    overflow: hidden;
    display: block;
    position: relative;
    height: 100px;
    width: 100%;
    margin-right: 10px;
    margin-left: 10px;
}

...

Add HTML for the AdSense Ad:

Add the following HTML code where you want the AdSense ad to appear (preferably just before the </body> tag):
html


...

<div class='stky-ads jhfdiuh0' id='stky-ads'>
      
<div class='stky-ads-close' onclick='document.getElementById(&quot;stky-ads&quot;).style.display=&quot;none&quot;'>
<svg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'>
<path d='M278.6 256l68.2-68.2c6.2-6.2 6.2-16.4 0-22.6-6.2-6.2-16.4-6.2-22.6 0L256 233.4l-68.2-68.2c-6.2-6.2-16.4-6.2-22.6 0-3.1 3.1-4.7 7.2-4.7 11.3 0 4.1 1.6 8.2 4.7 11.3l68.2 68.2-68.2 68.2c-3.1 3.1-4.7 7.2-4.7 11.3 0 4.1 1.6 8.2 4.7 11.3 6.2 6.2 16.4 6.2 22.6 0l68.2-68.2 68.2 68.2c6.2 6.2 16.4 6.2 22.6 0 6.2-6.2 6.2-16.4 0-22.6L278.6 256z'/>
</svg>
</div>   
<center>
<div class='stky-ads-content'> 

<div>
<center>
<div> 

 <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
    <ins class="adsbygoogle"
         style="display:block"
         data-ad-client="YOUR-AD-CLIENT-ID"
         data-ad-slot="YOUR-AD-SLOT-ID"
         data-ad-format="auto"></ins>
    <script>
         (adsbygoogle = window.adsbygoogle || []).push({});
    </script>

</div>
</center>
</div>
</div>
</center>
</div>

...

Replace "YOUR-AD-CLIENT-ID" and "YOUR-AD-SLOT-ID" with your AdSense ad client ID and ad slot ID.
Save Theme:

Click on the "Save theme" button to save your changes.
Preview and Adjust:

Preview your blog to see if the floating AdSense ad is displaying correctly. Adjust the CSS code as needed to fit your design.
Remember to comply with AdSense policies, and ensure that the ad placement adheres to Google's guidelines to prevent any issues with your AdSense account.

How to remove a child node from an XML file in dynamics 365 finance and operations using x++

· 0 Comments

In Microsoft Dynamics 365 Finance and Operations (D365 FO), you can use the below x++ codes to remove a child node from an XML file. If you want to remove all child nodes of a parent node in an XML file you can use RemoveAll() method. You can copy and paste the below codes and change them as per your requirement. Here's an example of how you can achieve this:

...

Xml File Format

------------------------------------

<?xml version="1.0" encoding="UTF-8">

<FirstElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<ThirdElement xsi:type="Attribute">

</FirstElement>

-------------------------------------

internal final class CodingSpiderCodingExamples

{  

   public static void main(Args _args)

   {

       FileIoPermission permission;

        XMLDocument xmlDoc = XMLDocument::newBlank();

        XMLNode rootNode;

        XMLNode Node1, Node2;

        XMLElement xmlElement;

        str ns = 'http://www.w3.org/2001/XMLSchema-instance'; 

        permission= new FileIoPermission('C:\\MyFile.xml','w');

        permission.assert();

        xmlDoc = XMLDocument::newBlank(); 

        //Parent node

        rootNode = xmlDoc.documentElement();

        xmlElement = xmlDoc.createElement('FirstElement');

        xmlElement.setAttribute('xmlns:xsi',ns);

        rootNode = xmlDoc.appendChild(xmlElement); 

        //Child node 1

        xmlElement = xmlDoc.createElement('SecondElement');

        xmlElement.setAttribute2('type', ns, 'Attribute');

        Node1 = rootNode.appendChild(xmlElement); 

        //Child node 2

        xmlElement = xmlDoc.createElement('ThirdElement');

        xmlElement.setAttribute2('type', ns, 'Attribute');

        Node2 = rootNode.appendChild(xmlElement);

       //Remove all child nodes

        rootNode.removeAll(); 

        // Save the file

        xmldoc.save('C:\\MyFile.xml');

   }

Output file

---------------------

<?xml version="1.0" encoding="UTF-8">

<FirstElement ></FirstElement>

...


Here root nod is the "FirstElement " node , other two nodes are child nodes, after executing the x++ codes , both cild noded will be removed from the xml file and you can see the output file.

How to get on hand inventory (quantity) of an item using x++

· 0 Comments

In Microsoft Dynamics 365 Finance and Operations (D365 FO), you can use the below x++ codes for getting on hand inventory (quantity) of an item. Here you need to pass the two arguments ItemId and  InventDimId. You can copy and paste the below codes and change them as per your requirement. Here's an example of how you can achieve this:

...

public InventQtyAvailPhysical onHandInventory(ItemId _itemId, InventDimId _inventDimId)

{

    InventOnhand    inventOnhand;

    InventDim       inventDim = inventDim::find(_inventDimId);

    InventDimParm   inventDimParm; 

    inventDimParm.initFromInventDim(inventDim);

    inventOnhand = InventOnhand::newParameters(_itemId, inventDim, inventDimParm);

    return inventOnhand.availPhysical();

}

...

When we pass the _itemId and _inventDimId values to the function, the method availPhysical(); returns the  on hand inventory (quantity) of the item.

10 common Excel functions and their equivalent SQL functions

· 0 Comments

Here are 10 common Excel functions and their equivalent SQL functions:

...

1. VLOOKUP (Excel) - JOIN (SQL): SQL's JOIN operation allows you to combine data from multiple tables based on a common key, similar to Excel's VLOOKUP which retrieves data from another table based on a matching key.


2. IF (Excel) - CASE (SQL): Excel's IF function allows you to perform conditional operations. In SQL, the CASE statement serves a similar purpose, allowing you to perform conditional logic.


3. CONCATENATE (Excel) - CONCAT (SQL): In Excel, CONCATENATE joins text strings together. In SQL, CONCAT combines strings from columns or literals.


4. TEXT (Excel) - TO_CHAR (SQL): Excel's TEXT function formats a number as text with a specified format. In SQL, TO_CHAR formats dates and numbers as text with a specified format.


5. INDEX/MATCH (Excel) - SELECT (SQL): Excel's INDEX/MATCH combination allows you to look up a value in a table. In SQL, you use the SELECT statement to retrieve data from a table based on specified conditions.


6. SUMIF (Excel) - SUM with WHERE (SQL): Excel's SUMIF function adds up values that meet a specified condition. In SQL, you can achieve a similar result using the SUM function with a WHERE clause to filter rows based on a condition.


7. AVERAGEIF (Excel) - AVG with WHERE (SQL): Excel's AVERAGEIF calculates the average of values that meet a specified condition. In SQL, you can use AVG with a WHERE clause to accomplish a similar task.


8. COUNTIF (Excel) - COUNT with WHERE (SQL): Excel's COUNTIF counts cells that meet a specified condition. In SQL, you can use COUNT with a WHERE clause to count rows that meet specific criteria.


9. IFERROR (Excel) - NULLIF (SQL): Excel's IFERROR function allows you to specify a value or action if a formula results in an error. In SQL, you can use the NULLIF function to return NULL if a specific condition is met.


10. TODAY (Excel) - CURRENT_DATE (SQL): Excel's TODAY function returns the current date. In SQL, you can use the CURRENT_DATE function to obtain the current date.

...


How to check null date field in dynamics 365 finance and operations using x++ code

· 0 Comments

In Microsoft Dynamics 365 Finance and Operations (D365 FO), you can check null date field in two ways using x++ code. You can copy and paste the below codes and change them as per your requirement. Here's an example of how you can achieve this:

...

internal final class CodingSpiderCodingExamples

{  

   public static void main(Args _args)

   {

        if (endDate != Global::DateNull()) 

        if (endDate != mkdate(1,1,1900))

   }

...


Global::DateNull() functions is used to check the null date field in Microsoft dynamics 365 finance and operations using x++ code.

Notexists Join in dynamics 365 finance and operations using x++ code

· 0 Comments

In Microsoft Dynamics 365 Finance and Operations (D365 FO), you can write the below code example for how to use notexists join in x++. You can copy and paste the below codes and change them as per your requirement. Here's an example of how you can achieve this:

...

internal final class CodingSpiderCodingExamples

{  

   public static void main(Args _args)

   {

        DlvMode    dlvMode;

        SalesTable  SalesTable;

        int i;    

        ttsbegin;

        while select forupdate dlvMode

        notexists join SalesTable where dlvMode.Code ==   SalesTable.DlvMode

       {

            dlvMode.delete();

            i++;

        }

        Info(strFmt("Total deleted records - %1", i));

        ttscommit;

   }

...

In the code snippet above, you can change the code as per your requirements.

How to get abc code of a customer or prospect in dynamics 365 finance and operations

· 0 Comments

In Microsoft Dynamics 365 Finance and Operations (D365 FO), you can get abc code of a customer or prospect in dynamics 365 finance and operations. you can copy and paste the below codes and change them as per your requirement. Here's an example of how you can achieve this:

...

internal final class CodingSpiderCodingExamples

{  

   public static void main(Args _args)

   {

   DirOrganization dirOrganization = 

   DirOrganization::find(smmBusRelTable::find(“Put your customer Account Number here”).Party);

   ABC abc = dirorganization.ABC;

   }

...


In the code snippet above, Put your customer Account Number here. After running the project the `info` statement displays 
abc code of a customer in an info log message. You can modify this part of the code to suit your requirements.

How to get fields name, type, mandatory and label of any AOT table or view in d365 fo using x++ code

· 0 Comments

In Microsoft  Dynamics 365 Finance and Operations (D365 FO), you can retrieve field names, types, mandatory status, and labels of any AOT table or view by using below code snippets. you can copy and paste the below codes and change them as per your requirement. Here's an example of how you can achieve this:

...

internal final class CodingSpiderCodingExamples

{  

   public static void main(Args _args)

   {

   DictTable           dictTable = new SysDictTable(tableNum(VendTable));

   FieldId               fieldId = dictTable.fieldNext(0);     

   DictField           dictField;

   while(FieldId)

   {

       dictField = dictTable.fieldObject(fieldId);

       info(strFmt("%1-%2-%3-%4", dictField.name(), dictField.mandatory(), dictField.baseType(), dictField.label()));

       fieldId = dictTable.fieldNext(fieldId);

   }

   }

...

Output:

How to get fields name, type, mandatory and label of any AOT table or view in d365 fo using x++ code

In the code snippet above, replace the table name with your required table name. After running the project the `info` statement displays field names, types, mandatory status, and labels in an info log message. You can modify this part of the code to suit your requirements, such as storing the Enum ID in a variable or using it for further processing.

Make sure to replace `TableName` with the appropriate name from your D365 FO environment.



How to retrieve enum Id from table field id in d365 fo using x++ Code

· 0 Comments

In Microsoft  Dynamics 365 Finance and Operations (D365 FO), you can retrieve the Enum ID from a table field ID by using the field.enumId() function. Here's an example of how you can achieve this:

...

internal final class CodingSpiderCodingExamples

{

public static void main(Args _args)

   {

SysDictField field = new SysDictField(tableNum(PurchReqTable), fieldNum(PurchReqTable, Requisitionstatus));

       info(strFmt("Enum Id: %1",field.enumId()));

}

...

Output :

In the code snippet above, PurchReqTable is the Table and Requisitionstatus is the enum field. After retrieving the Enum ID, the code uses the `info` statement to display the Enum ID in an info log message. You can modify this part of the code to suit your requirements, such as storing the Enum ID in a variable or using it for further processing.

Make sure to replace `TableName` and `FieldName` with the appropriate names from your D365 FO environment.

Use Normal Table as Temp Table in Dynamics 365 Finance and Operations

· 0 Comments

Basically, Standard Dynamics 365 Finance and Operation projects contain many temporary tables and regular tables. Imagine a scenario in which you have to create a complex temporary table that is similar to an already existing regular table. In this situation, you can use the existing regular table as a temp table. As we already read, InMemory tables are temporary tables that are held in the memory and written to a local disc after reaching a certain limit of the system, especially in an Application Object Server (AOS). So this method saves records on local disc/memory instead of saving them into the database. Also deleting records from the temporary table will not delete anything from the database.

In Microsoft  Dynamics 365 Finance and Operation projects you can use the following coding snippets to convert a regular table to a temp table.

As an example, we will use the vendor table to insert and display a couple of temporary records without affecting actual data. Yo create a Runnable Class named VendTableToTemp 

...

class VendTableToTemp
{   
  public static void main(Args _args)
 {
      VendTable vendTable;
      vendTable.setTmp();
      vendTable.AccountNum = '1001';
      vendTable.Blocked = CustVendorBlocked::No;
      vendTable.Party =Supplier 1;
      vendTable.doInsert();
      vendTable.clear();
      vendTable.AccountNum = '1002';
      vendTable.Blocked = CustVendorBlocked::All;
      vendTable.Party = Supplier 2;
      vendTable.doInsert();
      while select vendTable
     {
        info(strFmt( "%1 - %2", vendTable.AccountNum, vendTable.Name));
      }
 } 
}

...

In the code, we first call the setTmp() method on the vendTable table to make it temporary in the scope of this method. This means that any data manipulations will be lost once the execution of this method is over and the actual table content will not be affected.

The key method used here to convert a regular table to a temp table is setTmp(); 
which creates an InMemory Table which has the same structure as that of the original table. setTmp() : has nothing to do with deletion at all. It turns a buffer into a temporary one, therefore it saves records to memory/on disk instead of into the database. If you delete everything from the temporary buffer, it doesn’t delete anything in the database, obviously.
Next, we will use doInsert() to bypass any validation rules which are not required for a temporary table.

We have to keep in mind that even if the table becomes temporary; all the code in its insert(), update(), delete(), initValue(), and other methods are still present and we have to make sure that we don't call it unintentionally.

Container Data Type Example in Dynamics 365 Finance and Operations

· 0 Comments

A container is a “composite data type”, which contains an ordered sequence of values (primitive dataTypes – int, str, real, date, boolean, enum, etc.) or other containers or/and some composite data types. A container can be stored in the database as a database column created through AOT especially used to store images/files as a blob.

The below example code shows how to declare a container and how to add values to a container also the example shows how to retrieve the data from a container, Here we have declared three containers "EmpId" "EmpName" and "Salary",  where "EmpId" stores employee ids, "EmpName" stores the name of the employees and "Salary" stores employee salary. For declaring a container we use the keyword "Container" the container name.

...

class ContainerExample
{
   /// <summary>
   /// Runs the class with the specified arguments.
   /// </summary>
   /// <param name ="_args">The specified arguments.</param>
   public static void main(Args _args)
   {
       container EmpId;
       container EmpName;
       container Salary ;
       int i;
       EmpId=[1000,1001,1002,1003];
       EmpName=["James","John","Peter","Dev"];
       Salary=[50000.00,45000.00,75000.00,40000.00];
       for(i=1;i<=4;i++)
       {
           info(strFmt("EmpId
= %1 -- EmpName = %2 -- Salary  = %3",conPeek(EmpId,i),conPeek(EmpName,i),conPeek(Salary,i)));
       }
   }

...

Here an "[] " bracket is used to assign the values to the container and values are comma separated. 
For example, container EmpId, which stores employee ids [1000,1001,1002,... etc], and container EmpName, which stores employee Names["James", "John",...etc]. this is the way a container stores data.

Then how to retrieve data from containers?. The conPeek() is used to retrieve a specific element from a container. 

From the above example, it is very clear that values from container EmpId are retrieved by using the code conPeek(EmpId, i), where EmpId is the name of the container and "i" is used for the position of the element to be returned. Similarly, way data are retrieved from EmpName and Salary containers. You can copy and paste the above codes directly to your visual studio.

Calculate totals of PO using X++ in D365FO

· 0 Comments

In Dynamics 365 FO, calculating totals of a purchase order using X++ code is given as above, copy and paste the above codes, and then,

  • Create a runnable class (job) named as CalculateTotalsOfPurchaseOrder
  • Copy the below code and paste it into the newly created class
  • Change the Purchase order id according to your system’s data
  • Execute the job

...

internal final class CalculatePurchaseOrderTotals
{
   public static void main(Args _args)
   {
       //Calculate totals per Purchase order
       PurchTotals purchTotals;
       PurchTable  purchTable  = PurchTable::find('00000041'); //Change the Purchase Order Id as per your system's data
       AmountCur   totalAmount;
       purchTotals = PurchTotals::newPurchTable(purchTable);
       purchTotals.calc();
       totalAmount = purchTotals.purchTotalAmount();
       info(strFmt("Purchase order: %1 - Total value: %2", purchTable.PurchId, totalAmount));
   } 
}

...

  • Change the purchase order number according to your system data.
  • Successfully run the project.
  • you can see the purchase order total in the info log window.

Current Logged User Information using X++

· 0 Comments

The code below will help out in fetching current user Information in AX 7 or D365 FO. Here I fetch the basic details of logged users including User Id, Person Name, and working position. In Dynamics 365 FO user details and associated personal information are kept in different tables. But by using the below x++ codes, you can easily fetch the details. For this, you create a runnable class then copy and paste the below codes to the main method.

...

class RunnableUserInfo
{  
   public static void main(Args _args)
   {       
       HcmWorkerRecId              hcmWorkerRecId;
       HcmPositionWorkerAssignment hcmPositionWorkerAssignment;
       HcmPositionDetail           hcmPositionDetail;
       OMOperatingUnit             omOperatingUnit;   
       hcmWorkerRecId = HcmWorker::userId2Worker(curUserId());
       hcmPositionWorkerAssignment =   HcmPositionWorkerAssignment::getActivePositionWorkerAssignment(hcmWorkerRecId);
       hcmPositionDetail = HcmPositionDetail::findByPosition(hcmPositionWorkerAssignment.Position);       
       DirPartyName PersonName = DirPersonUser::userId2Name( curUserId());   
       info(strFmt("User Id : %1 - Name : %2 - Position: %3",
               curUserId(),PersonName,hcmPositionWorkerAssignment.description()));
   }
 
}

...

After the successful build of the project, you will get the output. You can elaborate the codes as per your requirement, by writing more codes you can also fetch more user details.

How to Open External URL in D365 Using X++ Code

· 0 Comments

If you want to navigate the user’s browser to a different URL programmatically (and not by providing a link they can click) this can be done very easily by using the new class Browser. With the new version of Dynamics AX or D365, there are new APIs that are needed because of technological changes.

...

class ExternalURL
{       
    /// The specified arguments.
    public static void main(Args _args)
    {
        Browser browser = new Browser();
        browser.navigate('http://www.google.com', true, false);
    }
}

...

The Browser class only has one single method, navigate, which has three parameters (of which only the first is mandatory):

     - URL (string)
     - Prompt (boolean)
     - Open in a new tab (boolean)

In Visual Studio Create One Runnable Class, In the main method write the below code. If you run it, it’ll open a new tab with the starting page of this blog. For best practice, you create an action menu set its object type to class, and set the object with the runnable class name. Add this menu item to the required menu extension. Save compile On clicking the menu item from navigation. A popup window opens, if your browser pop window is blocked, Allow the popup option. If this code helps you please share it with others.

Hello World Example in Java

· 0 Comments

In this program, we have a class called `HelloWorld`. The `main` method is the entry point of the program, where the execution begins. Within the `main` method, we use the `System.out.println` statement to print the string "Hello, World!" to the console.

...

public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

...

To run this program, you need to have Java installed on your system. You can use any IDEs to run the Java code. run the code and on the console window, the output will display.

How to write "Hello World" in HTML

· 0 Comments

In this HTML code, we have a basic structure starting with the `<!DOCTYPE html>` declaration, followed by the opening and closing `<html>` tags. Inside the `<html>` tags, we have the `<head>` section where we can specify the title of the web page using the `<title>` tag.

The content of the web page is placed within the `<body>` tags. In this example, we have an `<h1>` (heading) tag that contains the text "Hello, World!".

...

<!DOCTYPE html>
<html>
<head>
    <title>Hello, World!</title>
</head>
<body>
    <h1>Hello, World!</h1>
</body>
</html>

...

To see this HTML code in action, you can create a new HTML file, for example, `hello-world.html`, and copy the code into that file. Then, you can open the file in a web browser, and it will display "Hello, World!" as a heading on the page.

Alternatively, you can also use an online HTML editor or integrated development environment (IDE) to run and preview HTML code. Simply paste the HTML code into the editor, and it will show you the rendered output in real time.

That's it! You've created a simple HTML page that displays "Hello, World!" in a web browser.

How to run alert in JavaScript

· 0 Comments

The `alert` function in JavaScript is used to display a simple dialog box with a message and an OK button. In the example below, the message "Hello, world!" is displayed in the dialog box. When the `alert` function is executed, it pauses the execution of the script until the user clicks the OK button or closes the dialog.

Here's what happens when the code is executed:

1. The `alert` function is called with the string "Hello, world!" as its parameter.

2. The browser displays a dialog box with the message "Hello, world!" and an OK button.

3. The script execution is paused until the user interacts with the dialog box.

4. Once the user clicks the OK button or closes the dialog, the script resumes its execution.

The `alert` function is commonly used for displaying important messages or notifications to the user. However, it's important to note that `alert` can be intrusive and interrupt the user experience, so it should be used sparingly and only when necessary.

Note: In modern web development, the use of `alert` is often discouraged in favor of more sophisticated and less obtrusive methods of displaying messages, such as using HTML/CSS to create modal windows or using JavaScript libraries like Bootstrap or SweetAlert.

alert("Hello, world!");

JavaScript code that triggers an alert when a form is loaded:

In the below code, the `window. onload` event is used to execute a function when the entire page (including all its resources) has finished loading. In this case, the function triggers an `alert` that displays the message "Form loaded!".

When the web page is loaded, the JavaScript code inside the `<script>` tags is executed. The `window. onload` event waits for the page to load completely, and then it triggers the defined function, which displays the alert.

You can replace the `<!-- Form content goes here -->` comment with your actual form HTML code. When the form loads, the `alert` will be triggered and display the message.

Remember to include this JavaScript code inside the `<script>` tags in the `<head>` or at the end of the `<body>` element, so that it's executed when the page is loaded.

window.onload = function() {
      alert("Form loaded!");
    };        

JavaScript code that triggers an alert when a button is clicked:

In the below code, a JavaScript function named `showAlert` is defined. This function contains the `alert` statement that displays the message "Button clicked!".

The button element `<button>` is created with the text "Click me". It has an `onclick` attribute that specifies the function `showAlert()` to be executed when the button is clicked.

When the button is clicked, the `showAlert()` function is called, and it triggers the `alert` which displays the message.

You can modify the `showAlert` function to perform any other actions or display different messages as per your requirements.

Make sure to include this JavaScript code within the `<script>` tags in the `<head>` or at the end of the `<body>` element, so that it's executed when the button is clicked.

function showAlert() {
      alert("Button clicked!");
    }       

Call the function showAlert() in the onclick event of button

 onclick="showAlert()"

Site Sponsors