3

I have problem with CloudConnect application. I'm trying to write a transformation code in REFORMAT component, but there is a problem with if function. Maybe the problem is with =, but I have no idea how to fix it.

function integer transform() {
    $out.0.date = str2date($in.0.Date, "yyyy-MM-dd");
    $out.0.price = str2decimal($in.0.Amount);
    if ($in.0.Purpose = 'A') {return "Facebook";} else if ($in.0.Purpose = 'B') {return "Google Adwords";} else {return SKIP;};
    return ALL;
}
Sam R.
  • 16,027
  • 12
  • 69
  • 122
user3402692
  • 47
  • 1
  • 4

2 Answers2

4
if ($in.0.Purpose == 'A') {return "Facebook";} else if ($in.0.Purpose == 'B') {return "Google Adwords";} else {return SKIP;};
Pinu
  • 382
  • 3
  • 4
  • Thank you, but there is another problem. I have function integer transform, but metadata are in string, so I can't use this transformation. Do you have any idea which function I should use? – user3402692 Mar 14 '14 at 14:26
  • The problem here is that you cannot call return "Facebook" but you need to assign the Facebook value to the output metadata field that is String. The return is "integer value" and is a result of the whole transformation function. – Jiri Tobolka Mar 17 '14 at 09:53
3

Like in other programming languages, the single equal sign (=) is the assignment operator. That is,

$in.0.Purpose = 'A'

assigns the value 'A' to $in.0.Purpose variable. In your case, you need to use the comparison operator (==).

aleshak
  • 91
  • 2