Copy data generated by QUERY

I want to copy the values generated by a complex scripted query to another sheet, for users to work on without deleting the original query.

The query generates a variable range of data, depending on parameters passed, so I cannot hard code the range to copy. But it seems the problem is more complex than that…

Sample query and output

I tried to pick the range using GetDataRange(); that returns an error (TypeError: Cannot call method “getDataRange” of null.).

  // copy data to dashboard:   var dashTab = thisSht.getSheetByName("Dashboard");   dataTab.getDataRange().copyTo(dashTab.getRange('A5'), PASTE_VALUES, false); 

Checking that there is data there:

  var dataRange = dashTab.getRange('B6');   Logger.log(dataRange); 

shows an empty array [[]] in the log.

So how can I do this?

Microservice JOIN query

I know this question came up by a lot of people here and around the Internet but I couldn’t manage to find a really clear explanation how to do queries spanning multiple microservices.

Imagine that I have 2 services, one is managing user relations, and one is responsible for blog posts. If I just want to get the 20 latest posts, I have to query the relations database for ALL my friends/follows. That could be a thousand entries. Then I pass these to the blog service and it returns 20 blog posts. Then I scroll down a bit and (imagine that I don’t cache) this operation is repeated. This is an overkill in my opinion.

Most of the answers to these questions stated that the separation of domains is not good, and if these two services are always used together then they belong to one service. That’s also unacceptable for me because most of us are just writing our programs in microservice way, but all the features are somehow coherent. So in the end if I’d have many joins I’d always be building monoliths? Or should I accept the inefficiency if I go on the microservice path?

¿Porque me salta error del query?

estoy en urgencia con un proyecto web y esperaba que alguno me pudiera ayudar con este pequeño problema. me salta error al conectar con la base de datos. no se si alla puesto algo erroneo, les agradeceria mucho su ayuda.

Codigo PHP


        $  subs_rol = 2;         $  subs_name = $  _POST['name'];         $  subs_last = $  _POST['last'];         $  subs_user = $  _POST['user'];         $  subs_email = $  _POST['email'];         $  subs_pass = $  _POST['pass'];         $  subs_passnew = $  _POST['pass_new'];         $  reqlen = strlen($  subs_user) * strlen($  subs_email) * strlen($  subs_pass) * strlen($  subs_passnew);          if ($  reqlen > 0) {              if ($  subs_pass === $  subs_passnew) {                  require('sql/db_conection.php');                 $  subs_pass = md5($  subs_pass);                  $  sql="INSERT INTO users VALUES ('','$  subs_rol','$  subs_user','$  subs_name','$  subs_last','$  subs_email','$  subs_pass','$  subs_passnew')";                  mysqli_query($  db_connection,$  sql) or die ('Error en el query');                  mysqli_close($  db_connection);                  echo 'Correcto';              } else {                 echo 'Porfavor, introduzca dos contraseñas identicas.';             }         } else {             echo 'Porfavor, rellene todos los campos requeridos.';         }          } 


En la parte “mysqli_query($ db_connection,$ sql) or die (‘Error en el query’);” me salta el error.

LINQ or Lambda for two foreach query

The code I have written works fine, this inquiry being purely for educational purposes. I want to know how others would do this better and cleaner. I especially hate the way I use two for loops to get data. There has to be a more efficient way.

I have got a Document Name Table in my SQL database and Files in Content Folder. I have got a Two list- ListOfFileNamesSavedInTheDB and ListOfFileNamesInTheFolder.

Basically, I am getting all file names saved in Database and checking is it exist in the Folder, if not delete file name from the database.

 var clientDocList = documentRepository.Documents.Where(c => c.ClientID == clientID).ToList();   if (Directory.Exists(directoryPath))             {                 string[] fileList = Directory.GetFiles(directoryPath).Select(Path.GetFileName).ToArray();                 bool fileNotExist = false;                 foreach (var file in fileList)                 {                     foreach(var clientDoc in clientDocList)                     {                         if (clientDoc.DocFileName.Trim().ToUpper()==file.ToUpper().Trim())                         {                             fileNotExist = false;                             break;                         }                     }                      if (fileNotExist)                     {                         //Delete file name from Database                     }                 }             } 

Mysql query to get all columns and its sub contents from other table by its id

I have two tables named “tasks” and “comments”.

I want to get all tasks from “tasks” table.

“comments” table has 2 columns: description and task_id.

task_id is foreign key from task table.

$  tasks = DB::table('tasks')        ->join('comments','', '=','comments.task_id')        ->select('tasks.*','comments.* as comments')        ->get(); 

This code returns error.

How can I do this?

How to pass and capture query string parameter to newform in modal dialog?

My modal dialog for newform is not capturing the query string value I’m trying to pass to it. Alert on main page confirms the qs value for XID is set correctly.

    var xid = GetUrlKeyValue("ID", false, location.href);     var xurl = "";     var xmodal = xurl + "/Lists/List_Tasks/NewForm.aspx?XID=" + xid;      $  ('#WebPartWPQ5 #idHomePageNewItem').attr('href', '#');     $  ('#WebPartWPQ5 #idHomePageNewItem').attr('onclick', function () {         return "javascript:showDialog('" + xmodal + "');"     });      function showDialog(url) {         var options = {             autosize: true,             url: url,         };         SP.UI.ModalDialog.showModalDialog(options);     } 

I have the following placed in a script editor at the bottom of the newform to capture the qs value for XID. Nothing, alert is empty.

<script src=""></script> <script type="text/javascript">   $  (document).ready(function () {      var xid = GetUrlKeyValue("XID", false, location.href);     alert(xid);   }); </script> 

Tried this, same. Alert is empty. Console: Cannot read property ‘SPGetQueryString’ of undefined.

<script src=""></script> <script type="text/javascript">   $  (document).ready(function () {     var queryStringVals = $  ().SPServices.SPGetQueryString();     var xid = queryStringVals["XID"];     alert(xid);   }); </script> 

Tried placing in a form loaded event instead of $ (document).ready, no luck. Got sick of qs and tried passing args, that didn’t work either.



So, I removed the function showDialog as it is not being used at all. javascript:showDialog just opens the dialog with the specified url.

Using console.log(location.href) on the newform shows the XID from the querystring is not being passed. Why?

$  ('#WebPartWPQ5 #idHomePageNewItem').attr('onclick', donothing());  function donothing() {   console.log("hello"); } 

This override of the onclick event is doing nothing, literally. You can use this format to change the text, but it isn’t doing anything for the onclick event.

$  ('#WebPartWPQ5 #idHomePageNewItem').text("add something"); 

Redirection Plugin: Change permalink structure to remove date, want to retain and pass query strings (?utm_)

I have changed the permalink structure from /%year%/%monthnum%/%postname%.html to /%postname%/

I have added the following regex rule to the Redirection plugin:

Source URL: ^/([0-9]{4})/([0-9]{2})/([^/]+).html(.*)$   Target URL:$  3/ 

This works and redirects links from social media appended with ?utm_medium=social&utm_source=pinterest etc., but strips that parameter from the target.

How may I edit my regex to have it pass the query string and append it to the new URL format?

Thank you.

How do I limit query results, when distinct isn’t distinct?

I have a bill of material file that I am trying to reduce to only the unique parts, and related data for the line. The problem I’m running into is multiple instances of a part number due to variations in the formatting or language in the part name from the system/s that a third party pulls the data from. pn123 part_name pn123 Part-name pn123 Part name pn123 German name

All other fields I select are equal, how do I limit this in the where clause to just one instance of the above for all different part numbers? Is there an equivalent to MAX() in a text string?

I am working around the issue in excel, by deleting the dupes.

select distinct  adhoc.ats_esh.Customs_Entry_Num [VIN]as [Qlickview VIN] ,[Build_Date] ,[BOM_Level] ,[9802].[Supplier] ,[Part_number] ,[Part_Name] *******THIS IS THE PROBLEM FIELD******* ,[Unit_Price] ,[Usage] ,[Extended_Price]  from    adhoc.IMFM_9802_EU_AP [9802] inner join ADHOC.ATS_ESL     ON [9802].VIN = ADHOC.ATS_ESL.Part_Num         inner join adhoc.ATS_ESH     ON ADHOC.ATS_ESH.Trans_SK = ADHOC.ATS_ESL.Trans_SK        where  adhoc.ats_esh.importer ='ACME_CO' and adhoc.ATS_ESH.ENTRY_SUMMARY_DATE >= '2/01/2018' And adhoc.ATS_ESH.ENTRY_SUMMARY_DATE < '3/01/2018' AND adhoc.ats_esl.Supplier in('supplier1','supplier2','supplier3')  --and adhoc.ats_esl.Part_Num like '%ABC%'  --and [BOM_Level] = '1' --**** use MAX()