Freshdesk Webhook - Get data from subject to populate a custom field - webhooks

Has anyone tried to get a string from a ticket subject and populate a custom field using Webhooks on Freshdesk?
I am trying to get a reservation number that starts with the letter 'R' and put it on a custom field.
Example code:
<script>
var strng;
strng = "Either way, time largely defines the human experience.";
var incStr = strng.includes("human");
document.write("Is 'human' present in the string? : " + incStr);
</script>
{
"custom_fields": {"Resv#": incStr}
}
enter image description here

Related

Add multiple sameday events Calendar in sheets - Script AutoRun [duplicate]

I'm trying to create calendar events in sheets using Google App Script (I'm very new to this). The sheet contains details of the event (date, time, event title, and guest list) as well as the calendar ID (this is a training calendar). I want to make it simple for the end-user to fill in the information on the sheet, click 'schedule now' and the script run and send the events out to all email addresses mentioned in the guest list.
Here is an example of the sheet:
Here is a copy of the code (I found this on the Google Developer website and tried to adapt it to add guests but haven't been able to get it working and really not sure where to go with this. Ideally, I'd like the guest list to come from the sheet and not be written into the code as an option.
function scheduleTraining() {
var spreadsheet = SpreadsheetApp.getActiveSheet();
var calendarId = spreadsheet.getRange("C3").getValue();
var eventCal = CalendarApp.getCalendarById(calendarId);
Logger.log(eventCal)
var signups = spreadsheet.getRange("A5:C20").getValues();
for (x=0; x<signups.length; x++) {
var shift = signups[x];
var startTime = shift[0]
var endTime = shift[1]
var title = shift[2]
eventCal.createEvent(title, startTime, endTime, {
location: 'remote',
description: 'snacks provided',
})
}
}
function onOpen(e) {
SpreadsheetApp.getUi()
.createMenu('Schedule Training')
.addItem('Schedule Now', 'scheduleTraining')
.addToUi();
}
If anyone can help with this or has any ideas on how to do this better, I'm all ears!
Thanks!
Issues:
The dates in your spreadsheet file are strings/texts. You can verify that if you do =isDate(A7). If the latter returns FALSE then you don't have a valid date object. If you see the official documentation you need to pass date objects and not date texts.
Another remark I have is that your range is "A5:C20" but you should start from A7. Row 5 and 6 don't contain the information required, according to your screenshot.
Question based on your comment:
how I can include inviting the guests when it's run
Again according to the documentation, you can add guests using the advanced parameters options and in particular guests:
eventCal.createEvent(title, startTime, endTime, {
location: 'remote',
description: 'snacks provided',
guests: 'test1#gmail.com,test2#gmail.com'
})
guests is a type of string that contains a comma-separated list of email addresses
that should be added as guests.

SuiteScript Script sending statements

I couldn't find an answer to this in docs or here. Is it possible to script sending statements to customers? thanks for any help you can give.
Yes, but it's even easier to do it with a workflow. We created a custom field for a 'Statement Contact' and set up a scheduled workflow based on a 'Saved Search Filter' which basically checks that the customer has a balance. There is one state which contains a single 'Send Email' action. The 'Send Email' action has the option to 'Include Statement'. It fires on the 4th day of each month - you can set this or any other parameter to whatever suits you. This works fine for us, so I hope it helps you.
I found this in SuiteAnswers, it is enough for my purposes.
function printStatement()
{
//this is is the customer id
var id = nlapiGetRecordId();
var email = nlapiGetFieldValue('custentity_accounting_email');
//create an array to set the STATEMENT properties(optional)
var sdate = new Array();
sdate.startdate = '11/01/2015'; // replace it as per requirement
sdate.statementdate = '11/30/2015'; // replace it as per requirement
sdate.openonly = 'T'; // replace it as per requirement
sdate.formnuber = 112; // replace it as per requirement
//print the statement to a PDF file object
var file = nlapiPrintRecord('STATEMENT', id, 'PDF', sdate);
//send the PDF as an attachment
nlapiSendEmail('-5', email, 'Regular Statement', 'Please see attached Statment', null, null, null, file); //change the value of author id.
}

NetSuite: How do I populate a custom transaction field with the ship-to custom address field

In NetSuite, how do I populate a custom transaction field
(custbody_site_no_shipto)
on a transaction (for example, a Sales Order) with a custom address field
(custrecord_site_no)
for the Ship-To Address selected (under the Shipping tab)?
Custom transaction field: custbody_site_no_shipto
(Menu: Customization > Lists, Records, & Fields > Transaction Body Fields – Display Type is Inline Text).
Custom address field: custrecord_site_no
(Menu: Customization > Lists, Records, & Fields > Other Custom Fields – Checked Apply To All Custom Address Forms).
Usually, you would configure the sourcing of the custom field on the 'Sourcing and Filtering'.
However, shipping address is not included the 'Source List'.
So to cater that requirements, you might only do automation/customization either by SuiteFlow or SuiteScript (Client Side or User Event script).
And looking to your requirements, it seems you can only do this using after submit user event script. It is because the "Address" you wanted to access is a subrecord and not all APIs for it can be used on client side script. I have example below:
var recSO = nlapiLoadRecord('salesorder', 34826,
{
recordmode : 'dynamic'
});//34826 is the internal id of SO
var recSubAddress = recSO.viewSubrecord('shippingaddress');//Ship To field id
var stSiteN0 = recSubAddress.getFieldValue('custrecord_site_no');
recSO.setFieldValue('custbody_site_no_shipto', stSiteN0);
var stRecId = nlapiSubmitRecord(recSO);
The script below works and was implemented as a User Event Script.
function userEventBeforeSubmit(type) {
var shipadd = nlapiGetFieldValue('shipaddresslist');
var customer = nlapiGetFieldValue('entity');
var record = nlapiLoadRecord('customer', customer,{recordmode: 'dynamic'});
var linenum = record.findLineItemValue('addressbook', 'internalid', shipadd);
record.selectLineItem('addressbook', linenum);
var subrecord = record.viewCurrentLineItemSubrecord('addressbook', 'addressbookaddress');
var customfield1 = subrecord.getFieldValue('custrecord_site_no');
nlapiSetFieldValue('custbody_site_no_shipto', customfield1);
}

How to specify the class selector in web scraping using nodejs

Am trying to implement scraping using nodejs. Am sending request to a particular url and when i get the response, using the response am storing each products in a page into an array. For each product am trying to display the product details like product name, price and discount etc. Am doing this by the following code.
var $products = $body.find('.fashion-item');
$products.each(function (i, item) {
var $name = ($(item).find('.info .title').text(),
$price=$(item).find('span.price.regular').text().substr(6),
$discount=$(item).find('span.price.percentoff').text().slice(0,2);
self.items[i] = {
title: $name,
price: $price,
discount: $discount,
};
});
console.log(self.items);
It is working fine. If the class name is like 'fashion-item' or 'fashion-item-first' all this works fine. But if the class name contains the space in between the word, am not getting any products stored in array ($products) i.e. array length of $products is zero. My question is how to do the same thing if class name like this 'fashion-item first'. I tried very much, but i didn't get any idea. Please help me.
Class names cannot have spaces. In your example, 'fashion-item first', are two classes assigned to an element, which can be selected by either .fashion-item or .first selectors.
If you want item who have both info and title classe select them with this :
$(item).find('.info.title')
If you want item one of these classes, use this
$(item).find('.info,.title)

Sharepoint List redirect with new id

I have a list within Sharepoint, using a custom new form I have added a custom list form control ("New item form" for the list) and changed the SaveButton to a standard input HTML button, and added an 'onclick' event that is as follows:
onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={NewFormWizard2.aspx?id=}')}"
This works as in saves the data and redirects to the NewFormWizard2.aspx?id= page.
How do I get the ID of the created item to be passed to the redirected page?
Thus once the form is completed it would redirect to NewFormWizard2.aspx?id=23
jtherkel was close, but was missing a '}' on the end of the redirect url. I used an extra concat below
<input type="button" value="Submit" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent(concat('__commit;__redirect={lists/MyListName/DispForm.aspx?ID=',/dsQueryResponse/Rows/Row/#ID,'}'))}" />
I am not sure where the ID will exist on the page you host the Javascript from. Does it appear in the querystring or on a field on the page?
There is nothing in the request or response that will identify the item. I have had this issue when doing some web loadtesting.
I can only suggest that your create the item using the webservices as that at gives you some return xml.
This answer does not solve the "new form" issue, but it might help others with the syntax for screens that contain existing list items.
I tested this quickly in my SharePoint (MOSS 2007) environment.
onclick="javascript: {ddwrt:GenFireServerEvent(concat('__commit;__redirect={NewFormWizard2.aspx?id=',/dsQueryResponse/Rows/Row/#ID))}"
The concat syntax is an XSLT instruction that tells the processor to combine the values enclosed in single quotes. I adapted this answer from info I found here.
Loading Values in a Custom List Form
http://wssdevelopment.blogspot.com/2007_04_01_archive.html
I hope this would be helpfull:
1- In SharePoint Designer create new page, call it for example "LastItem.aspx" and place a dataview on it with a single form view for the destination list item.
2-Limit paging to just one record, set the sorting by ID and descending and filter the list to just show item which is created by [current user].
3-Now you do not need to pass any query string to this page. just replace the default "OK" button in NewForm.aspx of the list with a standard HTML input button and add this to its definition "onclick="javascript: {ddwrt:GenFireServerEvent(concat('__commit;__redirect={LastItem.aspx}". After submitting a new item to list you will be redirected to an edit view of the created item.
You can do the same for save button in LastItem.aspx to redirect to some other page after clicking on save button.
found an approach using pure javascript (JQuery) and the SPAPI code from http://darrenjohnstone.net/.
The list contains two fields, title and BodyCopy
I've thewn created a form that asks for a title and a question, both text fields, then the submit button calls the following function: (note that ServerAddress and LIST_question need to be updated to your own details).
The function then uploads the details using the SOAP service within LISTS.ASMX and using the response gets the ID of the new item and redirects the page.
var LIST_question = '{xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}';
var ServerAddress = 'http://xxx/';
function submitQuestion()
{
var title = new String($("#title").val());
var t = new String($("#question").val());
t=t.trim();
if(t=="")
return;
title=title.trim();
if(title=="")
return;
var lists = new SPAPI_Lists(ServerAddress) ;
//
var newItem = { Title : title, BodyCopy : t};
var items = lists.quickAddListItem(LIST_question, newItem);
var id=-1;
if (items.status == 200)
{
var rows = items.responseXML.getElementsByTagName('z:row');
if(rows.length ==1)
{
var r = rows[0];
var id = r.getAttribute('ows_ID');
window.location.href='DispForm.aspx?ID='+id;
}
else
{
alert("Error: No row added");
}
}
else
{
alert('There was an error: ' + items.statusText);
return;
}
}
You can achieve this using JavaScript http://www.sharepointdrive.com/blog/Lists/Posts/Post.aspx?ID=9

Resources