Saturday, 2 February 2019

CRM Portal Codes

=======================================================================
function retrievedata(SQrequestType) {
    $.ajax({
        crossOrigin: true,
        method: "GET",
        url: "/WebPage/",
        datatype: "json"
    }).fail(function (jqXHR, textStatus, error) { ShowLocationErrorMsg(error, null); })
        .done(function (result) {
            if (result.data[0].HasError) {
             
            }
            else {
                var FetchDetails = result.data;
             
                if (FetchDetails != null) {
                    var dropdown = $("#new_buid");
                    dropdown.empty();
                    $.each(FetchDetails, function (m, location) {
                        if (SQrequestType == "MCA" || SQrequestType == "Usage") {
                            var option = $('<option>').text(location.name).val(location.businessunitid);
                            FetchDetails.push(option);
                            $("#new_buid").html(FetchDetails);
                        }
                     
                    });
                    dropdown[0].selectedIndex = -1;
                }
            }
        });
}


function ShowLocationErrorMsg(errorMsg, errorObj) {
    console.log("In ShowLocationErrorMsg ");
    alert("Error:" + errorMsg);
    console.log("Error: " + errorMsg);
}


=====================================================================

{% fetchxml portalQuery %}
<fetch>
  <entity name="businessunit">
    <attribute name="name"/>
    <attribute name="parentbusinessunitid"/>
    <attribute name="businessunitid"/>
    <attribute name="locationtype"/>
     <attribute name="isdisabled"/>
    <order ascending="true" attribute="name"/>
    <filter type="and">
      <condition attribute="locationtype" value="96224" operator="eq"/>
      <condition attribute="isdisabled" value="0" operator="eq"/>
    </filter>
  </entity>
</fetch>
{% endfetchxml %}
{% assign locations = portalQuery.results.entities %}
{
    "data" :
    [
    {% if locations and locations.size > 0 %}
    {% for item in portalQuery.results.entities %}
    {
        "name": "{{item.name}}",
        "businessunitid": "{{item.businessunitid}}"
    }
    {% unless forloop.last %},
{% endunless %}
{% endfor %}
{% else %}
{
  "name": "",
  "HasError": true, "Body": { "Message": "No results found" }
}
{% endif %}
]
}

====================================================================


{% assign details =request.params['refidata'] %}


{% fetchxml MsgData %}

   <fetch mapping="logical" version="1.0" distinct="false" output-format="xml-platform">
  <entity name="casemessage">
    <attribute name="casemessageid" />
    <attribute name="message" />
    <attribute name="createdon" />
    <attribute name="messagestatus" />
    <order descending="false" attribute="message" />
    <filter type="and">
      <condition value="{{ request.params['id'] | xml_escape }}"  attribute="casemessageid" uitype="casemessage" uiname="" operator="eq" />
    </filter>
  </entity>
</fetch>

{% endfetchxml %} [ {% for item in MsgData.results.entities %}

{ "source":"{{ item.messagetypes }}",
    "status":"{{item.messagestatus}}"

}

{% unless forloop.last %}, {% endunless %}
{% endfor %} ]


function GetMsgStatus(statusid) {
    var source;
    $.ajax({
        crossOrigin: true,
        method: "GET",
        url: "/msg/?id=" + statusid,
        dataType: "json",
        async: false

    }).fail(function (jqXHR, textStatus, error) { ShowErrorMsg(error, null); })
        .done(function (result) {
         
            var order = result;
            order.forEach(function (element) {
                status = element.status;
           
            });
        });

    return status;
}
====================================

No comments:

Post a Comment