I need to get a lookup fields value from a line item on an SO and then update the corresponding line item in a PO. Fetching the value is not a problem, I'm using
newSite = record.getSublistValue("item", "custcol_site", lineNum)
to get the value - this returns the id of the lookup field object. However when I then try to update the field value on the PO using
loadedTransaction.setSublistValue({
sublistId: "item",
fieldId: "custcol_site",
value: newSite,
line: lineNum
});
Nothing happens, I don't get an error, however the field doesn't update either. How can I update the field using this ID value I've already fetched?
I'm also updating a number of other fields without issue following the same pattern, it's only the lookup field that's not updating successfully, so "lineNum" and fieldIds are not the problem as far as I can tell, I must just not be sending the correct information to update the lookup, however I can't find somewhere to tell me what information to send through.
Inferring from the name loadedTransaction that you have called record.load() to retrieve that reference, you'll also need to then call loadedTransaction.save() to commit your changes to the database.
Are you committing the line item before saving the record ?
recordObj.commitLine('item');
Related
In SSJS I'm using doc.getDocument().getItemValue(dateFld)[0] to access the date field value.
For one and only one particular document, I'm getting "Error while accessing indexed property #'0' on ojbect class java.util.Vecotr Array index out of range: 0
I checked the field on that document and it has a date-time value; the format is no different from the documents that are working correctly. I even ran SSJS code that did a typeof on the field value and measured its size: it's a vector and its size is 1.
I've tried resetting the field value on the document. I've tried removing the field, then resetting it, to no avail.
This is the second time I've come across this problem concerning a date field. Anyone have any suggestions?
You are getting this error because the item isn't in the backend document. Try using
doc.getDocument().getItemValueString("...")
or any other method that will return a "real" value instead of the Vector crap.
BTW: Don't use the [x] style to access the Vectored value - use .elementAt(x) instead when using the Vector returning methods :-)
I would add the following around your code, to assign a default value if the date field doesn't exits
if(doc.getDocument().hasItem(dateFld)){
//You code when the document exists
}else{
//Assign default value
}
I created workflow that will send an automatic email and create case record when user create order. The email sends and a case record is created but I have problem that some fields not transferred.
For example, I tried to pass the 'Order Requested Delivery Date' field to the new case 'Description' field. The case record created but the description field is empty.
I would check 3 things.
1) is the "Order Requested Delivery Date" populated on the source record (order)? Sometimes field names can get mixed up easily or you can be pulling the correct field name but from the wrong table
2) What does the audit history of the created record say? Was the field set on creation and then subsequently removed for one reason or anything?
3) Are specific fields on the target record not ever populating? Data type mismatches could be the culprit here.
I want to set the value of a custom customer field. The field type is List/Record and the value must be from a custom list.
I believe I have to set the value to the internal ID value of the custom list item. The items look like this:
Am I right that I have to use the ID value? Instead could I set the customer field to the Value value?
Assuming that I have to set the customer field to the ID value, I want to load all the items into memory and then look up the ID by the Value, like this:
The problem is that I cannot work out how to download the items using SuiteTalk. I can use CustomListSearchBasic to get the custom list record:
But I can't seem to get the items in the custom list.
Please can you help? Also, I'd be delighted to know how to work this out for myself. The schema browser didn't help.
I worked it out. I needed to set searchPreferences.bodyFieldsOnly = false
I want to add attachment to some specified List items, I used the function SPlist.GetItems(SPQuery) to get target list item, since there are many columns in the List, In order to limit the columns returned, I specified the ViewFields as below and set the "ViewFieldsOnly" property of SPQuery to "true".
query.ViewFields = "<FieldRef Name='Attachments' />";
I got the list item correctly and the "Attachments" property of returned SPListItem object is not null. However, after I used SPListItem.Attachments.Add() and trying to invoke SPListItem.Update(), an error
"value does not fall within the expected range" occur.
After looking into this issue, I found that if the "ViewFieldsOnly" property of SPQuery is set to "false", that error won't occur and the attachment will be uploaded successfully. But this will return all columns of the List item and makes my program run slower.
So my question is, is there a "mandatory" column that may block attachments from being attached to List item?
I encountered same error but I guessed it was due to udpate requires few more fields.
I found the blog and agree with that.
So leaving ViewFieldsOnly to default (false) is the only choice in case of updation.
I have one table called: Transaction. This table has the following fields: (ID,ProductName,Amount,Date) placed in an excel sheet that is connected with MS Access database. ID is the only unique field. Sometimes, my user submits a transaction that has let's say 5 records. Then, they want to modify the submitted data in case if they entered incorrect amount and they want to correct it. I want to write a code in VBA that will do the update. my current query is:
Update table Transaction(ProductName,Amount) set ProductName=#Product,Amount=#Amount)
where Date=#date;
This query does not work fine because obviously it replaces all the records data with the data of the last resubmitted record because my condition is weak. My difficulty is that I can't find a good condition in the where clause that will do the update a record by record accordingly.
Please help,
You will need to use the unique id of the record, in your case the ID field to guarantee you are updating the correct record.
Something like the following:
Update table Transaction(ProductName,Amount) set ProductName=#Product,Amount=#Amount) where ID = "id of record you want to update"
Enjoy!