Hi I am attempting to create a estimate in a suite...
# suitescript
r
Hi I am attempting to create a estimate in a suitelet and i'm getting
Copy code
INVALID_FLD_VALUE
You have entered an Invalid Field Value 80974 for the following field: item
This item works in the ui for this customer, Here is my code, Thanks
Copy code
const rec = record.create({
    type: record.Type.ESTIMATE,
    isDynamic: true
  })
  rec.setValue({ fieldId: 'entity', value: 1003 })
rec.selectNewLine({ sublistId: 'item' })
  rec.setCurrentSublistValue({
    sublistId: 'item',
    fieldId: 'item',
    value: 80974
  });
  rec.setCurrentSublistValue({
    sublistId: "item",
    fieldId: "quantity",
    value: 1
  })
  rec.commitLine({ sublistId: "item" })
  const saved = rec.save()

I also tried with   const rec = record.transform({fromType:'customer', fromId:1003, toType:record.Type.ESTIMATE, isDynamic:true}); and same error
e
try using the the defaultValue key on
record.create
to set the customer Not 100% sure, but it may make a difference
Copy code
const rec = record.create({
    type: record.Type.ESTIMATE,
    isDynamic: true,
    defaultValues: {
        entity: 1003
    }
  })
Also worth confirming that your Item ID is correct- If you open that item record in NetSuite, look in the URL for id=XXXXXXX XXXXXX will be your item id In case the NAME of your item is 80974 but the Internal ID is different
An Internal ID of 80974 would mean that your instance has over 80,000 items in the system. If that feels wrong to you, then most likely the Item ID is NOT 80974
r
The id is correct and i tried defaultValues with no luck , thanks anyway
c
@reuben If you're using OneWorld, try setting the subsidiary first.
e
@Clay Roper In theory, shouldn't the Sub get sourced when the Entity is set?
c
@ericbirdsall I would hope so -- it's still possible that it's not, or that it's not sourcing in time for the item line operation. I've had some issues where sourcing in dynamic mode doesn't occur in time to satisfy a following operation. Less likely would be that the item is associated with a subset of subsidiaries smaller than that of the customer.
e
All fair points!
r
Thanks everyone, nothing works, i have my code in a map reduce , i tried it in a userevent and it works, I suspect in the map reduce the user is system which i logged out and it has a subsidiary of 1, when I ran the code in a user event my user has a subsidiary of 2, I'm not sure if thats whats going on
e
Interesting. Even when you hardcod the Subsidiary to 2 in the Map Reduce (like Clay suggested), when you log out the subsidiary, it shows 1?
r
no, the subsidiary for the customer is 2, when i log runtime.getCurrentUser it logs system with a subsidiary of 1, my user has a subsidiary of 2 as does all items
e
Ahh got it. Would you be able to use search.lookup on the customer to determine their subsidiary and then do
rec.setValue({ fieldId: 'entity', value: customerLookup.subsidiary[0].value})
to set the sub to the customers sub?
r
the customers are all 2 and items are 2