How do I get the field 'subsidiary.federalidnumber' in an Advanced PDF/HTML Template printed from Item Fulfillment? - netsuite

In the template I have the following code;
<p>1-${record.subsidiary.federalIdNumber}</p>
<p>2-${record.subsidiary.custrecord_invoice_company_email}</p>
<p>3-${record.subsidiary.custrecord_invoice_company_phone}</p>
The last two lines return the expected values but the federalIdNumber gives the following error:
ERROR: Field 'subsidiary.federalIdNumber' Not Found
I have also tried all lower case (federalidnumber), same error.
I know the field exist, works on other SO prints. Any other ways to get this field?

It's just ${subsidiary.federalidnumber} No record. prefix. It is the transaction's subsidiary not the user's though.
weirdly I just took a look at some working templates. note the test vs getting the value:
<#if record.subsidiary.fedralidnumber?has_content>
<b>GST Number: ${subsidiary.federalidnumber}</b>
</#if>

Related

Netsuite Invalid API usage. You must use getValue to return the value set with setValue

So I have an odd issue, When I create a new transaction and save, this error in the title gets thrown. But when I edit this transaction after it was created, the getText does not throw this error. Is there something I'm doing wrong or something special needed to getText on a create new record? Here is my code. This is for the afterSubmit method on my User Event Script for Vendor Bill screen. I just noticed getValue does work on create, does not produce this error, just don't understand why? Is this the correct way to get the value on create? To use getValue and getText cannot be used on create? Only for edit?
if (scriptContext.type == scriptContext.UserEventType.CREATE ||
scriptContext.type == scriptContext.UserEventType.EDIT) {
// get bill to index
var Bill = scriptContext.newRecord;
// fails on this call below on create but works on edit
var refno = Bill.getText({ fieldId: 'tranid' });
}
This behavior is described in the API documentation here.
In dynamic mode, you can use getText() without limitation but, in standard mode, limitations exist. In standard mode, you can use this method only in the following cases:
You can use getText() on any field where the script has already used setText().
If you are loading or copying a record, you can use getText on any field except those where the script has already changed the value by using setValue().
Apparently the newRecord object falls under the second criteria. At this point, the object only has values set. tranid will have a value with the transaction's internal ID, but it won't have the transaction name stored. To get the text, you will have to use record.load() to get the full record, or use search.lookupFields() to get just the transaction name.

Updating fiield in PostgreSQL table using .update() not working in django

I've been trying to update the invo_payment_method value from a table called Invoices. This is the code that I currently have to try to achieve this:
if total_payments_for_invoice.all().count() == 1:
invoice_object = Invoice.objects.get(slug=slug)
invoice_object.invo_payment_method = request.POST.get('payment_method')
invoice_object.save()
So what I'm trying to do is if it's the first payment for the invoice I want to get invoice_object which has the slug of the invoice that just got a payment and update the invo_payment_method field in the table and save the changes. But that's not working. I also tried doing the following:
if total_payments_for_invoice.all().count() == 1:
Invoice.objects.filter(slug=slug).update(
invo_payment_method=request.POST.get('payment_method'))
And it's not working either. After that I tried adding a the following to the code above:
if total_payments_for_invoice.all().count() == 1:
Invoice.objects.filter(slug=slug).update(
invo_payment_method=request.POST.get('payment_method')).save()
And this one actually updated the value in the database, but it made the webpage crash because of the following exception: AttributeError: 'int' object has no attribute 'save'. In case more information is needed, if I print the value of Invoice.objects.get(slug=slug) I get the following: INV-bb1c 21. And if I print the value of Invoice.objects.filter(slug=slug) I get the following: <QuerySet [<Invoice: INV-bb1c 21>]>. In both cases I'm getting the invoice number which is INV-bb1c and the invoice pid which is 21. Please see image attached of how the Invoice table looks like. Any help would be greatly appreciated. To clarify: invo_payment_method is initially null in the database and request.POST.get('payment_method') returns a string of the payment method used.

Netsuite Advanced PDF Template Issue on Save

It is really annoying, the below snippet was working until last week, something happened on the 2018.2 and its throwing me error when i try to save the Advanced PDF Template.
<#if !item.custcolprintonpdf>
The error message on Template is "For "!" right-hand operand: Expected a boolean, but this has evaluated to a hash+string (wrapper: com.netledger.templates.model.StringModel):"
It does not stop there, when i update it to <#if item.custcolprintonpdf != "true"> the template gets saved, and when i try to print the Invoice PDF, it gives me below error.
Left hand operand is a hash+boolean (wrapper:com.netledger.templates.model.BooleanModel).
Hope this is an Bug, anyone has any work around? Thanks in advance
Saw this in the NetSuite Professionals Slack Group:
I tried doing <#if item.istaxable> and it gave an error saying it
was a hash+string but then did <#if item.istaxable == true> and it
worked apparently it doesn't like to use a boolean with a true value
to signify truthiness all by itself.

Get data having a maximum attribute from firebase in nodejs

So i am working with firebase in nodejs, there is a "number" attribute in each of my document of a specific table(name generated at runtime). I want to get the data having the attribute "number"'s maximum value.
Here is my sample data:-
-L1GIb7Vyn6Yhd5gghH0
correct: blah
number: 9
question: A sample question
wrong1: blekh
wrong2: blahhh
I have seen answers like "childAdded" and all but all in vain also I can't use .endAt() or startAt() because I don't know the "number"'s value at any time.
My sample code till now is:-
queRef.child(req.session.quiztopicname+req.session.quiztopictype).
orderByChild("number").endAt(9).once("value",function(snapshot){
console.log(snapshot.val());
});
Use limitToLast(1) on your sorted reference/query to only retrieve the greatest value. Bear in mind that if there are multiple children with the same greatest value, you'll still only get one of them. There's more documentation or sorting and filtering here.

Access document when I have the UID

I have a combobox on my form that loads client names from a view using the format "name | UID" - this displays the client name on the form but saves the UID in the field.
I now want to use the UID to lookup the name for the client and save it in a field on the XPage that is not visible using the following code:
// ignore when UID is null
if (getComponent("parentUID").getValue() == null)
return false;
var UID:string = getComponent("parentUID").getValue();
var doc:NotesDocument = database.getDocumentByUNID(UID);
// now set your fields
document1.setValue("nachname", doc.getItemValueString ("nachname"));
document1.setValue("vorname", doc.getItemValueString ("vorname"));
I do this in a simple action attached to a button. The next simple action is a Save.
The code crashes with the following error:
Error while executing JavaScript action expression
Script interpreter error, line=8, col=42: [TypeError] Exception occurred calling method NotesDatabase.getDocumentByUNID(java.lang.String) null
I have copied the parentUID to a field on the document and I am getting the correct UID and the document exists in the database?
Any ideas?
PS: I am adding this to an existing application and the current document is not a response document - cannot change that unfortunately :o(
OK, I have found my problem - XPages returned the UID but it included a leading space. When I concatenated the values I did the following: "name | UID" i.e. I added a leading and trailing space to the pipe symbol to make the code legible - this was causing the problems.
It looks like you are missing the get.Value() in your getComponent line
Try getComponent("parentUID").getValue() == null
My guess is that this is causing the code to run when the UID is null. This means that the code is running when it really is null, and your effort to check for that isn't working.
Thanks for checking that.
Can you put in a print() statement and ensure that you have a value in the var UID.
Another thing, please capitalize the word "String" since java classes are capitalized.

Resources