Update fields with csv file

I am trying to create a job to update some new fields I added to an existing table in AX2009. I am having trouble figuring out how to update two of those fields which are NoYes checkbox fields. My csv file will have either a “Yes” or “No”. Can anyone point me in the right direction?

Hi Michelle,

You can use the LIKE function in AX to compare the value which you are getting from the CSV file and then insert the value into the table.

if (value Like “Yes”)

{

Table.field = NoYes::Yes;

}

else if (value Like “No”)

{

Table.field = NoYes::No;

}

value = Value which you get from CSV file.

Regards

Sindhu

Hi Sindhu,

If they changed the YES NO values in the cvs file to a 1 or 0 would they still have to use the LIKE function or would AX interpret the 1 and 0 like an enum?

Thank You,

-Mike

Hi Mike,

No if they use 1 or 0 instead of “Yes” or “No”, it wont work.

But as mentioned by Michelle, the csv file will contain Yes/No, this solution would be appropriate.(Yes and No in the job are just hard coded things")

Might be this code would work for both Yes\No and 1\0 :

static void ReadNoYesFromCsv(Args _args)

{

str value = “0”;

int length;

;

if ((strscan(value, ‘Yes’, 0 , strlen(value)) > 0) ||

(strscan(value, ‘1’, 0, strlen(value)) > 0))

{

value = ‘Yes’;

}

else if ((strscan(value, ‘No’, 0 , strlen(value)) > 0) ||

(strscan(value, ‘0’, 0, strlen(value)) > 0))

{

value = ‘No’;

}

}

Regards

Sindhu

Hi Mike,

No if they use 1 or 0 instead of “Yes” or “No”, it wont work.

But as mentioned by Michelle, the csv file will contain Yes/No, this solution would be appropriate.(Yes and No in the job are just hard coded things")

Might be this code would work for both Yes\No and 1\0 :

static void ReadNoYesFromCsv(Args _args)

{

str value = “0”;

int length;

;

if ((strscan(value, ‘Yes’, 0 , strlen(value)) > 0) ||

(strscan(value, ‘1’, 0, strlen(value)) > 0))

{

value = NoYes:Yes;

}

else if ((strscan(value, ‘No’, 0 , strlen(value)) > 0) ||

(strscan(value, ‘0’, 0, strlen(value)) > 0))

{

value = NoYes::No;

}

}

Regards

Sindhu

Hi Michelle,

You can find the updated job which will accept Yes\No and 1\0 from your CSV file :

static void ReadNoYesFromCsv(Args _args)

{

str value = “0”;

int length;

;

if ((strscan(value, ‘Yes’, 0 , strlen(value)) > 0) ||

(strscan(value, ‘1’, 0, strlen(value)) > 0))

{

value = NoYes::Yes;

}

else if ((strscan(value, ‘No’, 0 , strlen(value)) > 0) ||

(strscan(value, ‘0’, 0, strlen(value)) > 0))

{

value = NoYes::No;

}

}

Note : value - Value which you get from CSV.

Regards

Sindhu