Java Sript Conditions for AcrobatDC/LiveCycle Designer - acrobat

I creating Fillable PDF (Invoice) in Adobe LiveCycle Designer. I want Automatic fill field Value.
My point is I have 4 Different Items with different Code and diffrent Prices.
I have to ask about two field Field1 called " ItemCode" and Field2 called "UnitPrice". I want UnitPrice field automatically filled with ItemCode Price/Value.
Following are the item Codes and their Prices:
018/22.50$
019/39$
020/16$
234/55$
I want JavaScript For Adobe LiveCycle Designer and Adobe Acrobat DC.
Million of thanks.

I would do it like this (just one of many different possibilities:
Create a list of items, each item object gets two properties - id and price: (you can also write 22.5 instead of "22.50$" but then you'll have to take care of the formatting inside the UnitPrice field.
var itemList = [
{id:18,price:"22.50$"},
{id:19,price:"39$"},
{id:20,price:"16$"},
{id:234,price:"55$"}
];
In the exit event of the field that you type in the id write:
var idEntered = parseInt(this.rawValue);
for (var i in itemList){
if (itemList[i].id===idEntered){
UnitPrice.rawValue = itemList[i].price;
return;
}
}
Let me know if you need any help understanding my solution! :)

Related

Apply a date field value to expiration date in inventory details subrecord

I'm a newbie in NetSuite Scripting and was recently asked to apply the value from a date field (custbody_expiration_date) on item receipt transaction body to the expiration date field in the inventory details of all items when the item receipt is created.
Since there is no way to create a workflow on inventory details, I've managed to work out below codes however I'm keeping getting all sorts of different error message. Below is one of them after I click on save on item receipt.
Notice (SuiteScript)
org.mozilla.javascript.EcmaError: TypeError: Cannot find function getCurrentLineItemValue in object standard record. (/SuiteScripts/ARROW/Expiration_date_apply_to_all (1).js#27)
I am very confused on the difference between dynamic and standard mode, which functions should be used in which mode? Also, I am a bit hesitated on whether user event script is the correct way to go?
/**
*#NApiVersion 2.0
*#NScriptType UserEventScript
*#NModuleScope Public
*/
define(['N/record','N/search'], function (record, search) {
function beforeSubmit(context) {
var IRrecord = context.newRecord;
var numberOfLineItems = IRrecord.getLineCount({
sublistId: 'item'
});
var expirationdate = IRrecord.getValue({
fieldId: 'custbody_expiration_date'
});
for (var i=1; i<=numberOfLineItems; i++){
IRrecord.setSublistValue({
sublistId: 'item',
fieldId: 'item',
line: i,
value: true
});
//First get Lot Number and Quantity
var lotNumber = IRrecord.getCurrentLineItemValue('item', 'receiptinventorynumber');
var quantity = IRrecord.getCurrentLineItemValue('item', 'quantity');
var inventoryDetail = IRrecord.createCurrentLineItemSubrecord('item','inventorydetail');
inventoryDetail.selectNewLineItem('inventoryassignment');
inventoryDetail.setCurrentLineItemValue('inventoryassignment', 'issueinventorynumber', lotNumber);
inventoryDetail.setCurrentLineItemValue('inventoryassignment', 'quantity', quantity);
inventoryDetail.setCurrentLineItemValue('inventoryassignment', 'expirationdate', expirationdate);
inventoryDetail.commitLineItem('inventoryassignment');
inventoryDetail.commit();
IRrecord.commitLineItem('item');
}
nlapiSubmitRecord(IRrecord);
}
return {
beforeSubmit: beforeSubmit
}
});
Dynamic records are the kind you see client-side (as a rule) - modify a field value and some other field becomes refreshed and updated in real time. Forms sometimes need to have their fields filled in a particular order to prevent form completion errors triggering or field sourcing to work. For example, when entering a sales order, selecting the customer then defaults the sales tax when items are added to the order. Errors may be thrown at any point before the record save because a field is triggering dynamic sourcing (updating other fields), based on what has been entered.
Standard mode is - less dynamic. You populate the fields of the record in any order you choose, and when the save is performed, you choose whether sourcing (updating other fields from the data available) is triggered. Any errors in data entry are reported when the save is performed. I think it also has a lower client-side load as there are fewer AJAX queries being triggered.
Both are available in client-side and server-side javascript, but some record types cannot be updated client-side and must be done server-side using workflow actions, User Event, Restlet, Suitelets, or scheduled scripts. To the best of my knowledge, inventory subrecords on fulfillments, receipts and the like are one such type.
The way lines are updated changes between dynamic and standard mode. In dynamic mode, lines are selected, updated then committed and the methods used would be :
selectLine
setCurrentLineItemValue
commitLine (only do this if actually changing the line)
For standard mode, the way of changing lines is only to use setSublistValue and include the line number in the parameters.
Workflow action scripts will load the record in dynamic mode, but the load method can be investigated using the isDynamic() method on the record.
The other thing is, in SuiteScript 2, sublist lines are indexed from 0, not from 1 as your script is using. What's confusing is, in Suitescript 1, indexing was from 1. The code is using a mix of v1 & v2. nlapiSubmitRecord is v1, IRrecord.save is v2.
And for more information, see SuiteAnswer 79715 which explains how to set a value on the inventory detail on an item receipt. The example reloads the record in standard mode and updates the inventoryStatus field. SuiteAnswer 45372 explains the Record object and the difference between standard and dynamic modes. Take a look at SuiteAnswer 67605 which explains the basics of SuiteScript v2. SuiteAnswers is an amazing resource and the search is surprisingly good. I can also recommend Eric T Grubaugh's site (#erictgrubaugh) which has some great videos including comparisons between v1 & v2.

Bill Reference Number not populating in Xero API

I'm creating a bill (supplier invoice) in Xero API (C# .Net). Everything populates perfectly except for the Reference number which remains blank.
Excerpt:
var invoiceObject = new Invoice
{
Reference = "TEST123",
Contact = contact,
Date = DateTime.Now,
DueDate = DateTime.Now,
ExpectedPaymentDate = DateTime.Now,
Status = Xero.Api.Core.Model.Status.InvoiceStatus.Draft,
LineItems = lineItems,
Type = Xero.Api.Core.Model.Types.InvoiceType.AccountsPayable
};
var invoice = api.Invoices.Create(invoiceObject);
The following screenshot demonstrates the issue:
Every other field, lineitem, tax code, etc. populates perfectly.
I've tried different combinations of upper and lowercase characters, numbers, etc. but it doesn't work.
If I log in to Xero, open the Invoice and manually enter TEST123 an save the invoice, it works perfectly.
I've also tried saving the invoice, then editing it and re-saving in the API and the reference still does not populate.
How can I set the reference in the API?
Quick answer
Xero Invoice API docs indicate that you can't set the reference value for an ACCPAY invoice, but that whatever you put for the Invoice Number (which is a non-unique field on ACCPAY Invoices) will also appear in the reference field.
Explanation
I ran into this same issue. I found this comment on Xero's support forum:
https://community.xero.com/developer/discussion/40489223
... which says this:
Reference is presently slightly differently based on whether the
invoice is a sales invoice (ACCREC) or a purchase invoice/bill
(ACCPAY). For a bill the reference is presented in the InvoiceNumber
element, check our documentation on invoices here where we explain
this in more detail.
From the linked to docs
All that said, the screenshot you include in your post does have a "reference" input on it, but that's not an input for the invoice's reference value - that's an input for a possible reference value for a payment you enter against the invoice. The reference value for an invoice appears at the top next to the due date:
I have the exact same issue. I'm using Python Xero but hopefully, it is the same for Javascript.
In my case, I have to use InvoiceNumber instead of Reference for bills.

Transaction BODY Field from COLUMN Field (Netsuite)

I have an issue where some of our orders are being imported directly into Netsuite, and there is information from the first line item, that I need to copy into the transaction record (i.e. custom field on sales order)
I want to set this up so that it is automatic, I don't have access to the system that is used to bring the orders into Netsuite, and I only JUST got suitescript access and everything I read about that is way above my head..
I know basic HTML and some of the scripting formulas from Netsuite and that's all.
I was hoping there would be a CUSTOM FIELD FORMULA or some other similar way that I can just easily source the information directly from the first item in the item sublist?
This would be quite trivial to implement using SuiteScript. The example below assumes you want to copy the Memo field (description) from the first line item to the body Memo field. The basic idea would be something like the below (untested code):
function userEventBeforeSubmit(type){
if (type === 'create') {
var record = nlapiGetNewRecord();
var memo = record.getLineItemValue('item', 'memo', 1);
record.setFieldValue('memo', memo);
}
}
If want to accomplish this via custom fields etc. it is possible using "Custom Fields with Values Derived from Summary Search Results".
To do this create a Saved Search as follows:
Type: Transaction
Criteria: [none]
Results: Formula (Text), Summary
Type = Maximum, Formula: DECODE({line}, 1, {memo}, NULL)
Available Filters: Internal ID
Then create a Custom Transaction Body Field as follows:
Type: Free Form Text
Store Value: F
Validation & Filtering > Search: [Saved Search from previous step]
As this is a dynamically calculated field (Store Value = F), it would be available when viewing the record, but not in Saved Searches and lists. To remove this limitation, you can create a Workflow that would copy this field to another one that is stored.

SharePoint change column id for REST requests

I recently started experimenting with the REST API for SharePoint 2013 Foundation and I am trying to return all entries in a list. My GET request returns the data I am looking for, but the IDs used to identify the columns in the list are not helpful for identifying what the information is (see images below). The column IDs between 'Title' and 'ID', in the second image, are a jumble of characters.
SharePoint List View
Response Data
Is there any way to configure the list to use the column names as IDs? Also, is there some significance to the characters currently used as IDs?
You will need to make a second request to get a listing of columns that includes the InternalName and the Title which is what you are trying to reference:
You can use this REST call:
_api/web/lists/GetByTitle('Project Details')/fields
or you can use CSOM:
using (ClientContext context = new ClientContext(url))
{
List list = context.Web.Lists.GetByTitle("Project Details");
context.Load(list, l => l.Fields);
context.ExecuteQuery();
foreach(Field field in list.Fields)
{
Console.WriteLine(field.Title);
Console.WriteLine(field.InternalName);
}
}
SharePoint automatically generates the InternalName and it is a read-only field, at least using REST. It'll be easier to get the Field Data to correlate the InternalName to the Title than changing the values.
The column you are referring to, between Title and Id, is the ID of the content type associated to the item. It is not a column ID.
The SharePoint REST API is OData compliant, so you can use the $select parameter to query for the neccesary fields.
http://server/site/_api/web/lists('guid')/items?$select=Column1,Column2
Please be aware though, lookup fields need to be expanded as well, otherwise you get only the Id of the lookup item.
http://server/site/_api/web/lists('guid')/items?$select=LookupColumn&$expand=LookupColumn/Title

CRM 2011/2013. stopping header displaying "new contact" or "new property" etc

In CRM 2013 and 2011 I have some data that I've imported in. When you view the records they have, at the top in big letters "New Contact" or "New Account" etc depending on their type. I've looked at the form header and tried adding a field there (that I want displayed) thinking that it defaults to to new whatever since there is no other field. This is not the case. Primarily I'm using 2013, but the same thing happens in 2011 as well.
I tested to see if it's just for the imported records, but it also happens when I create new ones. Is this something that CRM does usually, and if so is there a way to tell it to display something else?
I believe what you're asking about is the way CRM displays the name of the Entity in the page title and the form header. If so, this is a (completely unsupported) function that I call to update the name of an entity in CRM 2011. I'm guessing it won't work for 2013 though.
setDisplayName: function (name) {
// Updates the Document Title
var title = parent.document.title;
var start = title.indexOf(':') + 2;
var end = title.lastIndexOf('-') - 1;
parent.document.title = title.substring(0, start) + name + title.substring(end);
// Sets the div Name
document.getElementById("form_title_div").childNodes[2].childNodes[0].innerText = name;
},
You can call it on the onLoad of the Entity and clear it, or set it to whatever you like.
What OP wanted was to remove the New Case label when creating a new Case (or any other entity)
I've done this today in CRM 2013 with this line
//Remove New Case label
document.getElementById("FormTitle").style.visibility = "hidden";