Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

JS is not working in localized content of web page dynamics portal

Posted on by 295

Hello Everyone!

Hope all of you are well! I created a web page in dynamics portal and added my custom JS code in localized content of web page but when my page loads so JS code does not execute. I also added " window.addEventListener('load', updateViewIdea); " method in my code but this method does not execute when page load. 

Can anyone tell me how to resolve this issue? I have also JS code in another localized content of web page with approximatly same code and that is running well . I do not know why this code is not running successfully.

*This post is locked for comments

  • Suggested answer
    oliver.rodrigues Profile Picture
    oliver.rodrigues 4,052 on at
    RE: JS is not working in localized content of web page dynamics portal

    can you please try clearing the cache... yourportalurl/_services/about

    you should be able to clear if you have portal admin access

    use the web forms to achieve the BPF you need.. it can be displayed the names of the steps.. to get same look & feel you will need JS/CSS.. but all the basics you can get using Portal Web Form

  • RE: JS is not working in localized content of web page dynamics portal

    no i did not clear cache after adding custom JS code in localized content of webpage. In console there is no error. I have also another page in which this same code is working properly but in this page this is not working. I want BPF on portal like following.

    bpf-on-portal.PNG

  • Suggested answer
    oliver.rodrigues Profile Picture
    oliver.rodrigues 4,052 on at
    RE: JS is not working in localized content of web page dynamics portal

    are you clearing the cache after changing the JS ? did you inspect the page to see if there is any errors in the console? is it only in that page the JS doesn't work.. or pretty much any page in your portal ?

    what is similar to BPF would be the Web Forms: docs.microsoft.com/.../web-form-steps

  • RE: JS is not working in localized content of web page dynamics portal

    By the way if you have BPF custom code to show BPF on dynamics portal so kindly share. I know BPF is not supported on portal.

  • RE: JS is not working in localized content of web page dynamics portal

    Dear i tried but not resolved

  • Suggested answer
    oliver.rodrigues Profile Picture
    oliver.rodrigues 4,052 on at
    RE: JS is not working in localized content of web page dynamics portal

    the last few lines which would be what triggers your code is commented out

    can you try the little piece of code that I sent previously? 

  • RE: JS is not working in localized content of web page dynamics portal

    debugger;

    function updateViewIdea() {
    try {
    alert("hello");
    debugger;
    console.log("distinguish log by shahroz");
    // Update status bar
    updateStatusBar(); // BPF Function

    showClosedReasonText();

    ChangeNoteButtonClass();

    // Hide status elements
    $("#unsw_ideastatus").hide();
    $("#unsw_ideastatus_label").hide();
    $("#unsw_ideadirection").hide();
    $("#unsw_ideadirection_label").hide();
    $("#unsw_backlog").hide();
    $("#unsw_backlog_label").hide();
    $("#unsw_isrequirements").hide();
    $("#unsw_isrequirements_label").hide();
    $("#unsw_viability").hide();
    $("#unsw_viability_label").hide();
    $("#unsw_concept").hide();
    $("#unsw_concept_label").hide();

    $("#unsw_bpfstagebeforeclose").hide();
    $("#unsw_bpfstagebeforeclose_label").hide();


    // Hide Update button
    $('#UpdateButton').hide();

    // Create simple bullet list from 'Who might benefit from this' answers
    var y = $('legend:contains("Who might benefit")');
    $(benefitList).insertAfter(y);

    appendChosenBenefit("unsw_students", "unsw_students_label");
    appendChosenBenefit("unsw_academicstaff", "unsw_academicstaff_label");
    appendChosenBenefit("unsw_professionalstaff", "unsw_professionalstaff_label");
    appendChosenBenefit("unsw_community", "unsw_community_label");
    appendChosenBenefit("unsw_other", "unsw_other_label");
    }
    catch (ex) {
    alert("Error in updateViewIdea method: " + ex.message);
    }
    }

    /**
    * Show a label text under the status bar with idea close reason
    * @return {Null}
    */
    function showClosedReasonText() {
    try {
    // Hide text area that shows comments on the form
    $("#unsw_ideaclosecomments").hide();

    //What is the reason text from the close comments text area?
    var reason = $("#unsw_ideaclosecomments").text();

    // If there is a value for close comments, add it to label at top of page
    if (reason.length > 0) {
    var reasonLabel = $("#ideaClosureReason");
    reasonLabel.html("Reason for Idea Closure: " + reason);
    }

    // Hide text area that shows comments on the form
    $("#unsw_ideaclosecomments").text = '.';
    $("#unsw_ideaclosecomments_label").hide();
    }
    catch (ex) {
    alert("Error in showClosedReasonText method: " + ex.message);
    }
    }

    /**
    * Update status bar
    * @return {Null}
    */
    function updateStatusBar() {
    try {
    // Hide completed stage
    // $("#status-Completed").hide();

    // Hide closed stage
    // $("#status-Closed").hide();

    // Hide closed stage
    // $("#status-ExternalDocumentAnalysis").hide();

    // Hide on-hold stage
    // $("#status-On-Hold").hide();
    // $("#status-On-Hold").attr('class', 'progress-done progress-current');

    var statusSelectControl = document.getElementById("unsw_ideastatus");
    var statusIndex = statusSelectControl.selectedIndex;
    // alert("Status Index : " + statusIndex);
    var directionSelectControl = document.getElementById("unsw_ideadirection");
    var directionIndex = directionSelectControl.selectedIndex;

    var isBacklog = false;
    if (document.getElementById("unsw_backlog_1").checked) {
    isBacklog = true;
    }

    var isRequirements = false;
    if (document.getElementById("unsw_isrequirements_1").checked) {
    isRequirements = true;
    }

    var isViability = false;
    if (document.getElementById("unsw_viability_1").checked) {
    isViability = true;
    }

    var isConcept = false;
    if (document.getElementById("unsw_concept_1").checked) {
    isConcept = true;
    }

    //alert("IsBacklog: " + isBacklog);
    //alert("isRequirements: " + isRequirements);
    //alert("isViability: " + isViability);
    //alert("isConcept: " + isConcept);


    switch (statusIndex) {
    case 1:
    //lodgement
    $("#status-Initiate").attr('class', 'progress-done progress-current');
    $("#status-Review").hide();
    $("#status-Finance").hide();
    $("#status-Validate").hide();
    $("#status-Finalize").hide();
    break;
    case 2:
    //External Document Analysys
    $("#status-Initiate").attr('class', 'progress-done');
    $("#status-Review").attr('class', 'progress-done progress-current');
    $("#status-Finance").hide();
    $("#status-Validate").hide();
    $("#status-Finalize").hide();

    break;
    case 3:
    // In consultation status
    $("#status-Initiate").attr('class', 'progress-done');
    $("#status-Review").attr('class', 'progress-done');
    $("#status-Finance").attr('class', 'progress-done progress-current');
    $("#status-Validate").hide();
    $("#status-Finalize").hide();

    break;
    case 4:
    // In assessment status

    $("#status-Initiate").attr('class', 'progress-done');
    $("#status-Review").attr('class', 'progress-done');
    $("#status-Finance".attr('class', 'progress-done');
    $("#status-Validate").attr('class', 'progress-done progress-current');
    $("#status-Finalize").hide();

    break;
    case 5:
    // Prioritisation

    $("#status-Initiate").attr('class', 'progress-done');
    $("#status-Review").attr('class', 'progress-done');
    $("#status-Finance").attr('class', 'progress-done');
    $("#status-Validate").attr('class', 'progress-done');
    $("#status-Finalize").attr('class', 'progress-done progress-current');
    break;
    }
    }
    catch (ex) {
    alert("Error in updateStatusBar method: " + ex.message);
    }
    }

    function updateStatusBarAsClosedOrCompleted() {
    try {

    var isBacklog = false;
    if (document.getElementById("unsw_backlog_1").checked) {
    isBacklog = true;
    }

    var isRequirements = false;
    if (document.getElementById("unsw_isrequirements_1").checked) {
    isRequirements = true;
    }

    var isViability = false;
    if (document.getElementById("unsw_viability_1").checked) {
    isViability = true;
    }

    var isConcept = false;
    if (document.getElementById("unsw_concept_1").checked) {
    isConcept = true;
    }

    var lastStatus = $("#unsw_bpfstagebeforeclose").val();

    if (lastStatus == "Initiate") {
    $("#status-Initiate").attr('class', 'progress-done');
    $("#status-Review").hide();
    $("#status-Finance").hide();
    $("#status-Validate").hide();
    $("#status-Finalize").hide();
    }
    if (lastStatus == "Review") {
    $("#status-Initiate").attr('class', 'progress-done');
    $("#status-Review").attr('class', 'progress-done');
    $("#status-Finance").hide();
    $("#status-Validate").hide();
    $("#status-Finalize").hide();
    }

    else if (lastStatus == "Finance") {
    $("#status-Initiate").attr('class', 'progress-done');
    $("#status-Review").attr('class', 'progress-done');
    $("#status-Finance").attr('class', 'progress-done');
    $("#status-Validate").hide();
    $("#status-Finalize").hide();
    }
    else if (lastStatus == "Validate") {
    $("#status-Initiate").attr('class', 'progress-done');
    $("#status-Review").attr('class', 'progress-done');
    $("#status-Finance").attr('class', 'progress-done');
    $("#status-Validate").attr('class', 'progress-done');
    $("#status-Finalize").hide();
    }
    else if (lastStatus == "Finalize") {
    $("#status-Initiate").attr('class', 'progress-done');
    $("#status-Review").attr('class', 'progress-done');
    $("#status-Finance").attr('class', 'progress-done');
    $("#status-Validate").attr('class', 'progress-done');
    $("#status-Finalize").attr('class', 'progress-done');
    }
    else {
    $("#status-Initiate").attr('class', 'progress-done');
    $("#status-Review").hide();
    $("#status-Finance").hide();
    $("#status-Validate").hide();
    $("#status-Finalize").hide();
    }
    }
    catch (ex) {
    alert("Error in updateStatusBarAsClosedOrCompleted method: " + ex.message);
    }
    }

    /**
    * Finds a value from a radio button and adds it to a new list
    * @param {Element} benefitItemSelect - Select control
    * @param {Element} benefitItemLabel - Label control
    * @return {Null}
    */
    function appendChosenBenefit(benefitItemSelect, benefitItemLabel) {
    try {
    // What is the selected index?
    var isSelected = document.getElementById(benefitItemSelect).selectedIndex;

    // If selected index is '1', then it is 'yes'. Else do nothing.
    if (isSelected == 1) {
    // Get the text value of the label
    var textValue = document.getElementById(benefitItemLabel).textContent;

    // Create a HTML list item
    var entry = document.createElement('li');
    entry.appendChild(document.createTextNode(textValue));

    // Add list item to list
    var list = document.getElementById("benefitList");
    list.appendChild(entry);
    }
    }
    catch (ex) {
    alert("Error in appendChosenBenefit method: " + ex.message);
    }
    }

    function ChangeNoteButtonClass() {
    try {

    var buttonControl = $('#notescontrol').find('a');

    buttonControl.attr('class', 'addnote primary btn btn-primary commentbutton');
    buttonControl.text("Add Comment / Document");
    buttonControl.width(210);
    }
    catch (ex) {
    alert("Error in ChangeNoteButtonClass method: " + ex.message);
    }
    }

    window.addEventListener('load', updateViewIdea);


    /* $(document).ready(function (){
    updateViewIdea();
    }); */

    /* window.onload = function() {
    debugger;
    updateViewIdea();
    }; */


    $('.page-heading').parent(".container").addClass("main-block");

  • Suggested answer
    oliver.rodrigues Profile Picture
    oliver.rodrigues 4,052 on at
    RE: JS is not working in localized content of web page dynamics portal

    can you share the code?

    can you try something as simple as:

    $(document).ready(function () {

       alert("hello world");

    });

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans