Skip to content

Instantly share code, notes, and snippets.

View rs77's full-sized avatar

Ryan rs77

View GitHub Profile
@rs77
rs77 / my_cs_custom_code.js
Last active March 11, 2023 02:56
This is the client script that needs to be uploaded to the File Cabinet. It does not need to be registered with a Script Record, but must satisfy the location of the User Event Script `clientScriptModule` (or the User Event Script's `clientScriptFileId`). More details here: http://scripteverything.com/update-record-with-button-when-viewing-in-br…
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define(['N/record', 'N/currentRecord', 'N/url'],
/**
* @param {record} record
* @param {currentRecord} currentRecord
* @param {url} url
@rs77
rs77 / my_ue_add_client_side_button.js
Last active March 11, 2023 02:56
How do you add a button on a record to perform an update to that record? Start with the User Event Script that needs to be uploaded to the File Cabinet and requires a Script Record. Then deploy the Script to the records that this needs to be attached to. More info here: http://scripteverything.local/update-record-with-button-when-viewing-in-brow…
/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
* Insert a client side button to update a record.
*/
define([],
() => {
const beforeLoad = (context) => {
try {
/** @type {Record} */
@rs77
rs77 / rename_folder_mac_os_using_python
Last active January 8, 2023 05:19
I had to rename the folders in a sub-directory on my Mac OS to lower case and this was the only code I could get to work. It appears you need to remove the directory and create a new one with the right case, you cannot simply use `os.rename`
import glob
import pathlib
import shutil
import os
src = '/Users/rds/Local Sites/biblejot/app/public_static/kjv/**/index.html'
temp = '/Users/rds/Local Sites/biblejot/app/public_static/kjv/temp/'
path = pathlib.Path(temp)
path.mkdir(parents=True, exist_ok=True)

I've noticed with the Explain Everything app that Powerpoint doesn't seem to work too well with it.

Upon importing a PPTX file from Dropbox into the Explain Everything app the font and settings of the Powerpoint slides weren't looking good. Here's a sample of how the imported Powerpoint file can look:

![](https://media.scripteverything.com/wp-content/uploads/2021/02/slide-within-powerpoint.jpg) Cover slide of a Powerpoint presentation within Powerpoint

If you want to embed a Google Map into your website and have a marker with an InfoWindow that you'd like to display once the page loads, you don't have to resort to using jQuery or window.onload events.

The following code alone is a working example for a recent task requirement.

In fact the solution is so simple you just need to add one more line to your initialize function.

Here's a basic sample with the solution:

<!DOCTYPE html>

How do you find the dimensions and position of a field when using the Adobe Sign REST API formFields endpoint so that you can then programmatically set where someone is to sign on your custom PDF?

When you're uploading a complete PDF document to Adobe Sign and programmatically setting where users are to sign using the formFields endpoint you need to set the formFieldsLocation property for each field which requires values for top, left, width, height and page number.

So how do you find the top and left distances in pixels for your field, along with its width and height?

Unfortunately, there's nothing helpful in Adobe Sign’s edit PDF area that can help provide this detail. Instead you need to download Adobe Acrobat Pro.

Finding Field Properties Using Adobe Acrobat Pro

If you find yourself using the .indexOf() function on many variables to test whether or not a string existings in another string, then this little handy tip can help write a comparative statement quicker.

What does the ~ (tilde) actually do to a variable?

Let's have a quick look:

var n = -1;
console.log( ~n ); // => 0
console.log( ~~n ); // => -1

console.log( ~~~n ); // => 0

Further to my previous post on combining 2 columns into one column I've had to do some further work on this by now combining a number of unknown columns into one unique column and then sorting the result.

I've been able to achieve this and will demonstrate one way in how I've been able to get it to work. Let's use a working example to show how it works.

First, we'll acquaint ourselves with the old method of using this formula, which in this case would be the following for the following three columns (column A will be our results column):

=unique(transpose(split(join(";",A:A)&join(";",B:B)&join(";",C:C),";")))
![](https://media.scripteverything.com/wp-content/uploads/2021/02/join-multiple-columns-sorted-result.png)

If within a Modelled Sheet you have a date field and need to calculate how many periods the row has been active for, then you can create a formula to capture this.

If we assume we have an input account on our Modelled Sheet labelled StartDate then our formula for determining how many periods have happened since StartDate would be as follows:

( ( year( this ) - year( ROW.StartDate ) ) * 12 ) + ( month( this ) - month( ROW.StartDate ) )

This assumes the time stratum of the sheet is monthly.

What if I don't want negative periods in the result?

Working on a current site required me to enter icons before the widget title in a sidebar.

I knew that WordPress wouldn't allow such detail, and I didn't want to have to find another plugin to do what I thought would be a menial task... so by resorting to jQuery it ended up being quite easy to do.

The result was to try to achieve something like this:

Widget with corresponding icon displayed