Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
Jennifer_siders
Contributor III
Contributor III

Null value being passed from Global Variable

Hi,

 

I am using the below query in tSalesforceInput component.

 

" select id
from Account where Id = '"+globalMap.get("f4.AccountId" ).toString() + "' AND Brand__c in

( '"+globalMap.get("f4.Brand_1").toString() +"' ,
'"+globalMap.get("f4.Brand_2").toString() +"' ,
'"+globalMap.get("f4.Brand_3").toString() +"' )
"

The problem is, out of three global variables -  f4.brand_1, f4.brand_2, and  f4.brand_3 only one can have a value in one iteration, due to which the system throws null pointer exception.

 

How i resolve this?

 

Thanks.

 

 

Labels (2)
4 Replies
TRF
Champion II
Champion II

This one should work:

"SELECT id
  FROM Account WHERE Id = '"+globalMap.get("f4.AccountId" ).toString() + "' " +
	"AND Brand__c IN ('" +
	globalMap.get("f4.Brand_1") != null ? globalMap.get("f4.Brand_1").toString() :
		globalMap.get("f4.Brand_2") != null ? globalMap.get("f4.Brand_2").toString() :
			globalMap.get("f4.Brand_3").toString() +
	"')"

 

Jennifer_siders
Contributor III
Contributor III
Author

Hi @TRF , unfortunately, i am still getting a null point exception at tsalesforceinput. Could you please help me understand the query construction - i am actually bit confused with the syntax while using global variables(being from non programming background), using + or double quotes in the query below.

Jennifer_siders
Contributor III
Contributor III
Author

Also, if i need to construct a query using the syntax which utilises +, " " -

My query which need the conversion is :
select id from account where country IN ( 'GlobalMap.get(Country1) ' ,
'GlobalMap.get(Country2) ' ,
'GlobalMap.get(Country3) )
TRF
Champion II
Champion II

Consider a SOQL (or SQL) query as a string.
This string can be a constant such as "SELECT myField FROM myObject" or it may have variable parts for the condition.
Start by thinking what the request should look like, for example "SELECT myField FROM myObject WHERE myField = 'AAA'".
Here "AAA" is not fixed but is included into a global variable (let say myGlobal).
So, you need to construct the request with a fixed part, completed with the content of a global variable and an other fixed part to finish.
The result should be:
"SELECT myField FROM myObject WHERE myField = '" + (String)globalMap.get("myGlobal") + "'"

 

Pay attention at the globalMap.get syntax, the variable name is a constant "myGlobal" or contained into an other variable (Country2 for example in your case) which must be known to be used.