Sharepoint JSOM – Get List Items – Uncaught ReferenceError: Type is not defined

I have a customer web page added to my sharepoint site and i’m trying to retrieve items from a sharepoint list, but i keep getting a error. I am not sure where I am going wrong:

Here is the HTML code with the script tags to load the sp.js, sp.runtime.js, and sp.core.js files:


    <!DOCTYPE html>
    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    
    <head>
        <meta charset="utf-8">
        <title>Some Title</title>
        
        <script type="text/javascript" src="_layouts/15/sp.core.js"></script>
        <script type="text/javascript" src="_layouts/15/sp.runtime.js"></script>
        <script type="text/javascript" src="_layouts/15/sp.js"></script>
    </head>
    <body>
    <script src="index.js" charset="utf-8"></script>
    </body>
    </html>

Here is code from my Javascript file:


    SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function () {});
    document.addEventListener("DOMContentLoaded", function () {
        ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
        });
    
    var collListItem;
    
    function retrieveListItems() {
        alert("Start Retrieval");
        var clientContext = new SP.ClientContext();
        var oList = clientContext.get_web().get_lists().getByTitle('SomeList');
        alert(oList);
        var camlQuery = new SP.CamlQuery();
        collListItem = oList.getItems(camlQuery);
        clientContext.load(collListItem);
        clientContext.executeQueryAsync(
        Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed)
        );
        alert("Retrieved");
        }
        
    function onQuerySucceeded(sender, args) {
        var listItemInfo = "";
        var listItemEnumerator = collListItem.getEnumerator();
        while (listItemEnumerator.moveNext()) {
        var oListItem = listItemEnumerator.get_current();
        listItemInfo += '<strong>ID: </strong> ' + oListItem.get_id() +
        ' <strong>Title:</strong> ' + oListItem.get_item('Item ID') +
        ' <strong>FirstName:</strong> ' + oListItem.get_item('Procedure Name') +
        ' <strong>LastName:</strong> ' + oListItem.get_item('Document Number') +
        '<br />';
        alert("success");
    }
    
    alert("post");
    
    document.querySelector("#test").html(listItemInfo);
    }
    
    
    function onQueryFailed(sender, args) {
    alert('Request failed. ' + args.get_message() +
    'n' + args.get_stackTrace());
    }

This keeps failing due to the a uncaught reference error shown below and i’m not sure where I am going wrong.

Uncaught ReferenceError: Type is not defined
    at sp.core.js:2:213
(anonymous) @ sp.core.js:2
sp.runtime.js:2 
        
       Uncaught ReferenceError: Type is not defined
    at sp.runtime.js:2:322
(anonymous) @ sp.runtime.js:2
sp.js:2 
        
       Uncaught ReferenceError: Type is not defined
    at sp.js:2:203
(anonymous) @ sp.js:2
index.js:36 
        
       Uncaught ReferenceError: SP is not defined
    at index.js:36:1

Highchart – Column range as arrows

I am integrating column range chart but I want the column to appear as an arrow. The arrow could be facing downward / upwards based on if the value is increased or decreased.

I can’t seem to find any workaround to achieve this.

Below is a reference picture of what I am trying to achieve..

enter image description here

Highcharts.chart('container', {

    chart: {
        type: 'columnrange',
    },

    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
            'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    },

    series: [{
        name: 'Temperatures',
        data: [
            [-9.9, 10.3],
            [-8.6, 8.5],
            [-10.2, 11.8],
            [-1.7, 12.2],
            [-0.6, 23.1],
            [3.7, 25.4],
            [6.0, 26.2],
            [6.7, 21.4],
            [3.5, 19.5],
            [-1.3, 16.0],
            [-8.7, 9.4],
            [-9.0, 8.6]
        ]
    }]

});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>

<figure class="highcharts-figure">
    <div id="container"></div>
</figure>

How to add spinner while file is phase uploading in internal memory ? React or Javascript or any framework

Upload photos ( or any files ) in the computer’s internal memory. So I’m not making any api calls. But imagine that the files are 500 mb or larger. They need some time to load into the internal memory. During that load ( upload ) time should I add some spinners while they are loading? How do I do that? I tried FileReader but it doesn’t react to me

  const onChange = useCallback((file) => { 
    const reader = new FileReader(); 
    reader.onload = () => {
      console.log('loading...');  // THIS IS NO WORK. NOT TRIGGERING
    };

    let tempArr: any = [];  
    for (let file of filesArr) {  
      tempArr.push(file);
    } 
  }, []);



  <input multiple type="file" onChange={onChange} />

In my situation i am using React but solutions from any javascript framework are welcome…

want to display a browser add exception for my https url on iframe in angular

I am displaying a ‘https’ url on a iframe tag and I have created self signed certificate for that url. But in iframe, when I display the url it does not pop the add exception on the iframe itself but I have to manually open that url into a different tab and then accept the exception.

I want to display that url exception on the iframe so that I can add the exception then and there instead of opening it different tab.

Please help me with this if it is possible with iframe or any other way. I am fairly new to javascript.

Thank you.

Close other div when new is clicked

So I have this table with a menu dropdown, but I’m having trouble getting the divs close when I click on one of the other menu dropdown divs. This is because the JS looks for a click inside/outside of the class, but how can I change this?

I’m trying to avoid the user from opening multiple dropdown menus at the same time, like this:

img

Here is the working code to see the problem.

/* When the user clicks on the button, 
toggle between hiding and showing the dropdown content */
function wdc_jql_menu(menu_id) {
    document.getElementById(menu_id).classList.toggle("show");
}

// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
    if (!event.target.matches('.dropbtn')) {
        var dropdowns = document.getElementsByClassName("dropdown-content");
        var i;
        for (i = 0; i < dropdowns.length; i++) {
            var openDropdown = dropdowns[i];
            if (openDropdown.classList.contains('show')) {
                openDropdown.classList.remove('show');
            }
        }
    }
}
.wdc_jql_table{
    /* table width */
    border:1;
    width: 100%;
    border-spacing: 0;
    border-collapse: collapse;
    background-color: #2F2F35;
    table-layout:fixed; // Cells is fixed to the percentage the cells is assigned too
    word-wrap:break-word;
    color: white;
}

.wdc_jql_table thead, tr{
    /* table style - bottom borders to seperate rows */
    border-bottom: 1.5px solid #3A3B41;
}
.wdc_jql_table tr:last-child{
    /* table style - no border at last row */
    border-bottom: none;
}

.wdc_jql_table 
th:nth-child(1),
th:nth-child(2), 
th:nth-child(3),
th:nth-child(4){
    /* table child th align (project name, owner, jql) */
    text-align: left;
    font-size: 24px;
    padding: 5px;
}

.wdc_jql_table 
td:nth-child(1),
td:nth-child(2), 
td:nth-child(3){
    /* table child td align (project name, owner, jql) */
    text-align: left;
    font-size: 16px;
    padding: 5px;
}
.wdc_jql_table
td:nth-child(4){
    /* table child td align (...) */
    text-align: center;
    font-size: 16px;
    padding-top: 5px;
    padding-bottom: 5px;
    padding-right: 15px;
    padding-left: 10px;
}
.wdc_jql_col1{
    /* table col(project name) width */
    width: 20%;
}

.wdc_jql_col2{
    /* table col(owner) width */
    width: 20%;
}

.wdc_jql_col3{
    /* table col(jql) width */
    width: 50%;
}

.wdc_jql_col4{
    /* table col(...) width */
    width: 10%;
}

/* MENU DESIGN */

.dropbtn {
    background-color: #2F2F35;
    color: white;
    font-size: 16px;
    border: none;
    cursor: pointer;
}

.dropbtn:hover, .dropbtn:focus {
    background-color: #8D90A1;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f1f1f1;
    min-width: 160px;
    overflow: auto;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
  }
  
.dropdown-content a {
  color: black;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
}

.dropdown a:hover {background-color: #ddd;}

.show {display: block;}
<table id="others_jql" class="wdc_jql_table padding_jql_bottom">
    <col class="wdc_jql_col1">
    <col class="wdc_jql_col2">
    <col class="wdc_jql_col3">
    <col class="wdc_jql_col4">     
    <thead>
      <tr>
          <th>Project Name</th>
          <th>Owner</th>
          <th>JQL</th>
          <th></th>
      </tr>
    </thead>  
    <tbody id="table_body_others">
        <tr id="tr1">
            <td name="projectNameTable">td1</td>
            <td name="employeeNo">td2</td>
            <td name="jqlTable">td3</td>
            <td name="edit_personal"><button onclick="wdc_jql_menu('menu_1')" class="dropbtn">&#8942;</button>
            <div id="menu_1" class="dropdown-content">
                <a href="#Edit">Edit</a>
                <a href="#Remove">Remove</a>
            </div>   
        </tr>
        <tr id="tr2">
            <td name="projectNameTable">td11</td>
            <td name="employeeNo">td22</td>
            <td name="jqlTable">td33</td>
            <td name="edit_personal"><button onclick="wdc_jql_menu('menu_2')" class="dropbtn">&#8942;</button>
            <div id="menu_2" class="dropdown-content">
                <a href="#Edit">Edit</a>
                <a href="#Remove">Remove</a>
            </div>   
        </tr>
        <tr id="tr3">
            <td name="projectNameTable">td11</td>
            <td name="employeeNo">td22</td>
            <td name="jqlTable">td33</td>
            <td name="edit_personal"><button onclick="wdc_jql_menu('menu_3')" class="dropbtn">&#8942;</button>
            <div id="menu_3" class="dropdown-content">
                <a href="#Edit">Edit</a>
                <a href="#Remove">Remove</a>
            </div>   
        </tr>
    </tbody>
</table>

So the solution is to rewrite the JS to listen for the div ID and then close the other open/shown classes I guess, but how?

Access React Context data inside Axios Interceptor

I am currently creating a simple application where an user can login and after login he receives a token.

I am using React context to store that token, each subsequent request should be done with the token.

To not send the token on each request I want to include it in the intercptor, so I ended up with something like this:

HttpService:

import axios, { AxiosRequestConfig } from 'axios'

import { useToken } from '../context/AccessTokenContext'

const axiosConfig: AxiosRequestConfig = {
  baseURL: 'localhost:3000',
}

const http = axios.create(axiosConfig)

http.interceptors.request.use(function (config) {
  const { token } = useToken()
  if (config.url != '/users/login') {
    if (config?.headers?.common && token) {
      config.headers.common['Authorization'] = `Bearer ${token}`
    }
  }

  return config
})

export default http

AuthContext

import React, { createContext, ReactNode, useContext, useState } from 'react'

export const AccessTokenContext = createContext<{
  token: string | null
  setToken: (base: string | null) => void
}>({ token: null, setToken: () => null })

interface IAccessTokenProvider {
  children: ReactNode
}
export const AccessTokenProvider = (props: IAccessTokenProvider) => {
  const [token, setToken] = useState<string | null>(null)
  return (
    <AccessTokenContext.Provider value={{ token, setToken }}>
      {props.children}
    </AccessTokenContext.Provider>
  )
}

export const useToken = () => {
  return useContext(AccessTokenContext)
}

The thing is after login I do another request and the token was not set yet. Is there any easier way to do this? I tried to also store it just in memory without react, but with that I cant automaticly update the route, because it reacts to the token change.

Variable does not wait for axios result / response

I am doing a laravel application and I want to check if the ID number has been used. I want to do it using javascript, meaning before I submit the whole form on the server.

Here is what I got:

<input type="submit" id="send-form" value="Save">

<input type="text" id="myid" name="myid">

My JS code:

$('#submit-form').click(function(){
  var is_duplicate_id = checkIfDuplicate();

  console.log(is_duplicate_id);

  if(is_duplicate_id){
    return false;
  }
  else{
    return true;
  }

});

function checkIfDuplicate()
{
  var myid = $('#myid').val();
    
  axios.get('/api/check-id', {
    params: {
      myid : myid 
    }
  }).then(function(response){    

    console.log(response.data);
    return response.data;

  }).catch((error) => {
    toastr.error(error, 'Ooops!');
    return false;
  });
}

My problem is the console.log printout on the is_duplicate_id variable is undefined even though the console.log printout on the response.data variable is 1 or 0.

It seems like the is_duplicate_id does not wait for the result of the axios call, that is why it prints out undefined.

Hope you can point-out what I am missing.

twilio programable voice hold call php sdk

This post is hidden. You deleted this post just now.
i have same issue when i clicked on hold it hold the call of number but disconnected to the agen soft phone also why? i to fix it? my code is:

public function holdCall(){
$client = new Client(get_option('call_twilio_account_sid'), get_option('call_twilio_auth_token'));
$calls = $client->calls->read(
    array("ParentCallSid" => $_POST['CallSid'])
);
$twilioCall = '';
header('Content-Type: text/xml');
    $twilioCall = $client->calls($calls[0]->sid)->update(
        array(
             "url" => base_url().'lead_manager/Call_control/holdQueue',
             "method" => "GET"
        )
    );
    echo $twilioCall->to;
}

public function holdQueue(){
$to_number = $this->input->get('To');
$response = new VoiceResponse();
$response->enqueue($to_number, ['waitUrl' => base_url('modules/lead_manager/assets/wait-music.xml'), 'waitUrlMethod' => 'GET']);
header('Content-Type: text/xml');
echo $response;
}

fill an array with useEffect and map()

i am trying to give an array an initial value at every render,
This is what i got for the moment

const [activeMarket, setActiveMarket] = useState([]);
const Markets = [ ‘DE’, ‘ES’, ‘FR’, ‘UK’], i got the values after some filtering in the state.session.
const CountryCode = DE, i got the value after some filtering in the state.session.

and i am trying to fill an array at every render using these values
this is what i got for the moment

  useEffect(() => {
   markets.map((item) => {
    setActiveMarket([
      ...activeMarket,
      {
        id: item,
        isActiveMarket: true,
        brandName,
      },
    ]);
  });
}, []);

i keep getting an empty array, i don’t know what i am doing wrong exactly cause when i did this it worked but only with one object:

  useEffect(() => {
   setActiveMarket([
     ...activeMarket,
     {
       id: countryCode,
       isActiveMarket: true,
       brandName,
     },
   ]);
 }, []);

Uncaught (in promise) Type Error when trying to fetch for URL

I made a server using Node.js and used the Express framework. Once the server was running, I went to Google Chrome and when to inspect element and went to the console, and typed – fetch('http://localhost:7500'). I was expecting to get the CORS error(Which I wanted) but instead got this:

VM267:1          GET http://localhost:7200/ net::ERR_BLOCKED_BY_CLIENT

VM267:1          Uncaught (in promise) TypeError: Failed to fetch
    at <anonymous>:1:1

Is there any way to resolve this error?

convert HH:MM AM/PM time to 24 hours in javaScript

I have a drop list of times in AM/PM format. and I need to abstract the time difference in 24 hours

 const startTimeChanged = (val:string)=>
 {
  onChange('session_start_time', val);
  var start_time:number = convertTimeToMin(props.data.session_start_time)
  var end_time:number = convertTimeToMin(props.data.session_end_time)
  if(start_time >= end_time)
  {
    let new_end_time_in_clock:string = convertMinToHour(start_time + 30);
    console.log(new_end_time_in_clock)
    onChange('session_end_time', new_end_time_in_clock)
  }
}

so, how do I calculate the time difference here when I’m getting the two inputs in AM/PM.

Chart.js 3.7 version. How to modify legend label?

i am trying to edit it in the labels:{}, but only color is changing but not the text
do let me know if there is a way
plugins: {

        legend: {
            display: true,
            position: 'top',
            labels: {

                text: "qasim",
                color: "red",
            }
        },
        title: {
            display: false,

             text: "Status",
        },
        tooltip: {
            enabled: false,
            position: "nearest",
            external: ""
        }
    }

Search function in PHP

I’m trying to insert a search function into my website, the one I found can find data from multiple columns (which is great) but the problem is that after the search results get displayed, The text header isn’t showing (which isn’t good). Does anyone know how to show the search results including the text header? I’m still new to coding, sorry.

<script>
function tableSearch() {
  
  // Declare variables 
  var input, filter, table, tr, td, i;
  input = document.getElementById("myInput");
  filter = input.value.toUpperCase();
  table = document.getElementById("T_SJSM");
  tr = table.getElementsByTagName("tr");


  // Loop through all table rows AND COLUMNS, and hide those who don't match the search query
  for (i = 0; i < tr.length; i++) {
    td = tr[i].getElementsByTagName("td");
    var match = false;
    
    //Loop trough all columns
    for(var j = 0; j < td.length; j++) {
      if(td[j]) {
        txtValue = td.textContent || td.innerText;
        if (td[j].innerHTML.toUpperCase().indexOf(filter) > -1) {
          match = true;
        }
      }
    }
    
    //Match found in one or multiple columns
    if (match) {
      tr[i].style.display = "";
    } else {
      tr[i].style.display = "none";
    }
  }
}

</script>