RvN
RvN

Reputation: 153

how to get values for customfields of a custom record in Netsuite

I'm new to integration with Netsuite. I've created a custom record and some fields along with values in Netsuite app, now I want to get those values from Webservice request. I'm getting labels, but I'm unable to get values.

CustomRecordType record = (CustomRecordType)response.getRecord();     
CustomRecordTypeFieldList fields = record.getCustomFieldList();     
CustomRecordCustomField[] crcf = fields.getCustomField(); 

for(CustomRecordCustomField c:crcf) 
{ 
    System.out.println(c.getLabel()); 
}

Upvotes: 3

Views: 2374

Answers (2)

Viral Prajapati
Viral Prajapati

Reputation: 85

customRec.setTypeId("626");
customRec.setInternalId("202"); 

ReadResponse response=_port.get(customRec);

CustomRecord record=(CustomRecord)response.getRecord();
CustomFieldList fields=record.getCustomFieldList();

CustomFieldRef[] crcf=fields.getCustomField();
int i=1;
Map<String,Object> test=new HashMap<String,Object>();
for(CustomFieldRef c:crcf)
{
    System.out.println(c.getScriptId());
    if(c instanceof StringCustomFieldRef)
    {
        test.put(p.getProperty(c.getScriptId()),((StringCustomFieldRef)c).getValue());
    }else if(c instanceof DateCustomFieldRef)
    {
        test.put(p.getProperty(c.getScriptId()),((DateCustomFieldRef)c).getValue().getTime());
    }
    else if(c instanceof LongCustomFieldRef)
    {
        test.put(p.getProperty(c.getScriptId()),((LongCustomFieldRef)c).getValue());
    }
    //System.out.println(c.getLabel()+" fieldtypes:  "+c.getFieldType().getValue());
i++;
}
for(Map.Entry<String,Object> entry:test.entrySet())
{
    System.out.println(entry.getKey()+"--->"+entry.getValue());

Upvotes: 1

Suite Resources
Suite Resources

Reputation: 1164

This is C# or Java - not my strong ponit. However, after you load up the record, you should be able to do something like this:

record.fieldname

Upvotes: 0

Related Questions