Import “empty” value

Hi,
We use Agile version 9.3.0.2
I need to delete existing values from some of the attributes of more than 300 P/Ns  (the fields must be empty).
I’ve tried to do it by “Import” action, prepared Excel file with empty cells, but the action failed.
The values in the attributes remained without any change.
Can somebody help me?
Thanking in advance.

Yossef Tsalik
YTsalik@Kramerel.com
Dir: +972-73-2650239
Cell: +972-52-8226651

Add Comment
8 Answer(s)

Hi

You can try following code .

This will update manufacturer Parts with every value provided in Excel file even Empty value.

Thanks,

Purushottam

 

package com.lattice.Agile;

import java.io.ByteArrayOutputStream;

import java.io.File;

import java.io.FileInputStream;

import java.io.FileOutputStream;

import java.io.IOException;

import java.io.InputStream;

import java.io.OutputStream;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;
import com.agile.api.AgileSessionFactory;

import com.agile.api.IAgileSession;

import com.agile.api.IImportManager;
public class Test {
public static void main(String args[])

{

String srcFilePath="C:/Users/purushottam.khatal/Desktop/template.xls";

String srcFileType="ExcelFile";

// Null implies loading the default mapping

String mappingPath="C:/Users/purushottam.khatal/Desktop/TDR-TT_MAP.xml";

// Null implies do not transform

String transformPath=null;

String [] operations=new String[]{"manufacturerParts"};

List options=new ArrayList();

options.add("BusinessRuleOptions|ChangeMode=Authoring");

options.add("BusinessRuleOptions|BehaviorUponNonExistingObjects=Reject");
try {

System.out.println("start");

//s1.append(System.getProperty("java.version"));

HashMap params = new HashMap();

params.put(AgileSessionFactory.USERNAME, "username_here");

params.put(AgileSessionFactory.PASSWORD, "password_here");

AgileSessionFactory sesion_factory = AgileSessionFactory.getInstance("http://instance:port/Agile");

System.out.println("tryin to create session");

IAgileSession session = sesion_factory.createSession(params);

//Session Created
IImportManager imgr = (IImportManager)session.getManager(IImportManager.class);

byte[] logData=null;
logData=imgr.importData(stream2byte(new FileInputStream(srcFilePath)),

srcFileType, convertFiletoStream(mappingPath),

null, operations, options);

byte buf[]=new byte[1024*4];
File log_file = new File("log.xml");

OutputStream os = new FileOutputStream(log_file);

os.write(logData);

os.close();

} catch (Exception e) {

// TODO Auto-generated catch block

e.printStackTrace();

}
System.out.println("out of try block");
}

private static byte[] convertFiletoStream(String path) throws IOException{

if(path==null || path.equals(""))

return null;

return stream2byte(new FileInputStream(path));

}
private static byte[] stream2byte(InputStream stream)

throws IOException {

ByteArrayOutputStream outStream=new ByteArrayOutputStream();

byte buf[]=new byte[1024*4];

int n=0;

while((n=stream.read(buf))!=-1){

outStream.write(buf, 0, n);

}

byte[] data=outStream.toByteArray();

outStream.close();

return data;

}

}
Agile User Answered on July 6, 2020.
Add Comment

Unsure about Agile version 9.3.0.2 (so apologies if this isn’t helpful), but in 9.3.5.7;

Go to the Import window;

Click ‘Preferences’ (bottom-left)

On the ‘Parsing and Validation’ tab, go to the ‘Blank Data Action’ field and choose a value of ‘Overwrite Data’

RE: Import

Agile User Answered on July 10, 2020.
Add Comment

You are going to have to use code or upgrade. Starting with 9.3.5 (?) you can clear values with Import.

Agile Angel Answered on July 11, 2020.
Add Comment

Hi Yosi,

Basically Import doesn’t delete existing values from attributes but only replacing them by other values.
Suggest you’ll insert one character in the Excel (such as “-“) so the import will upload it instead of the existing values.

Agile Angel Answered on February 3, 2016.
Add Comment

Thanks.
I’ve thought about this solution (write something instead “empty”, for example “.”) , but it doesn’t suit me.
The field must be really empty

Agile User Answered on February 3, 2016.
Add Comment

As mentioned above, please find the part of Import/Export documentation about the reason of why it is not possible to clear a filled field with an empty value
Importing Blank Fields
When you use the Import Wizard, it cannot perform a destructive operation. Existing Agile data is always preserved, never destroyed. Therefore, you can’t import a blank value to a non-empty Agile field. The Import Wizard ignores blank source fields.

Agile Angel Answered on February 3, 2016.
Add Comment

OK.
Thanks.
But, perhaps is there another way for achievement of the “target”? Not only by Import…

Agile User Answered on February 3, 2016.
Add Comment

You can create a quick script in JAVA using Agile API.

The following code will iterate for all ITEMS and set to empty the field Page Three.FieldName.
You can implement your criteria or iterate a predefined list of object(for example by number)

 IQuery iQuery = (IQuery) session.createObject(IQuery.OBJECT_TYPE, "Items");
ITable resultTable = iQuery .execute();
 Iterator iterator = resultTable.iterator();
 while (iterator.hasNext()) {
 IRow currItemRow = (IRow) iterator.next();
IItem item = currItemRow.getReferent();
item.setValue("[Page Three.FieldName]", "");
 }
Agile Angel Answered on February 3, 2016.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.