I am having a difficult time identifying the item ...
# suitescript
a
I am having a difficult time identifying the item type. I do not want the loop to skip any description items. When there is a description item, it spits out blank but for other items it will give me the type (e.g. invtPart) Any ideas what the issue is?
Copy code
for (i = 1; i <= itemLines; i++){
			var itemId = nlapiGetLineItemValue('item','item',i);
               nlapiLogExecution('DEBUG','Item ID',itemId);
          	var itemType = nlapiLookupField('item',itemId,'type');
               nlapiLogExecution('DEBUG','Item Type',itemType);

			if	(itemType != 'Description' || itemType != 'Subtotal'){
			nlapiSetLineItemValue('item', 'custcol_pm_customer_requested_date', i, custReqDate);
            }
}
Thread in Slack Conversation
n
you don't need to do a lookup you can get the type on the line itself
@Aria Ghahari get "itemtype" on the line to identify the ehm, item type...
a
It gives me an error when I put itemtype. Let me give it a try again. Thanks @NElliott
So no error but the log shows nothing. Here is the adjusted code:
Copy code
for (i = 1; i <= itemLines; i++)
        {
			var itemId = nlapiGetLineItemValue('item','item',i);
          nlapiLogExecution('DEBUG','Item ID',itemId);
          var itemType = nlapiGetLineItemValue('item','itemtpe',i);
          nlapiLogExecution('DEBUG','Item Type',itemType);
			if	(itemType != 'Description' || itemType != 'Subtotal'){
			nlapiSetLineItemValue('item', 'custcol_pm_customer_requested_date', i, custReqDate);
            }
  			
		}
message has been deleted
n
Copy code
nlapiGetLineItemValue('item','itemtpe',i);
^^ itemtpe maybe you mean itemtype?
😉
a
lmao
its been a long day
n
ditto
a
My keyboard does not always register spaces when clicked. . . guess now I have to worry about the "y" key as well.
That worked perfectly! hank you @NElliott Now I just have to get the if loop to work. Thanks again! CHeers
n
the if should evaluate OK, I think the itemtype for Description items is "Description" unlike some of the others (inventory item for instance)
a
You are correct. It is "Description".But it is being ignored. I'm going to see i I can see why.
b
your code has a logical error
Copy code
if	(itemType != 'Description' || itemType != 'Subtotal'){
			nlapiSetLineItemValue('item', 'custcol_pm_customer_requested_date', i, custReqDate);
            }
the condition is equivalent to true
a
Supposed to be and?
b
depends on what you want, but an
&&
would set the field if the item type is not description and is not subtotal
a
Boom. That is what I wanted. I want to set the date for "regular" items only. && worked. Thank you @battk