Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
\"action\":\"getcondition\",

 

is

...

always

...

followed

...

by

...

the

...

following:

...

Code Block
\"filter\":\

 

 

In the following example code, getCondition is invoked when the CALREF1 field (Contact) from the activity is selected. If the CALREF2 field (Account) contains data, then Contacts (module 2) related to that account are displayed. If no Account is selected, then the ELSE statement returns all records using the following:

Code Block
\"action\":\"getcondition\", \"filter\":\"\" .

If

you'd

prefer

to

have

no

records

returned,

use

the

following:

Code Block
\"action\":\"getcondition\", \"filter\":\"1=2\"

 

...

Code Block
<html><head><title>GetConditionExample</title><scripttype="text/javascript"> 
function conditionQueryJSON(){
	return "[{\"action\":\"select\",\"invoke\":\"getConditionQuery\",\"parameters\":[{\"modulefields\": [ { \"module\":\"6\", \"fields\":\"CALREF2\"} ], \"filter\":\"\",\"isfromscreen\":\"yes\"} ] } ]";
}
function getConditionQuery(row){
	if (row[0]._6.CALREF2){
		return "[ {\"action\":\"getcondition\",\"filter\":\"2.uid in (select childid from me_datarelation where parenttype=1 and childtype=2 and ( parentid="row[0]._6.CALREF2" or devicerowidparent="row[0]._6.CALREF2" ) ) \" } ]";
	}else{
		return "[ {\"action\":\"getcondition\",\"filter\":\"\" } ]";
	}
} 
function onErrorInvoke(rows){ 
	if(rows.length > 0){
		window.location="melt://showAlert/"+ rows[0].message;
	}
}
</script></head><body></body></html>

...

Code Block
function conditionQueryJSON(){
	return "[{\"action\":\"select\",\"invoke\":\"getConditionQuery\",\"parameters\":[{\"modulefields\": [ { \"module\":\"6\", \"fields\":\"CALREF2\"} ], \"filter\":\"\",\"isfromscreen\":\"yes\"} ] } ]";
}
function getConditionQuery(row){
	if (row[0]._6.CALREF2){
		/** list the account's contacts which have job title of CEO**/
		return "[ {\"action\":\"getcondition\",\"filter\":\"2.CONTREF1="row[0]._6.CALREF2" and 2.CONTJOBTITLE=CEO\" } ]";
	}else{
		/** list all the contacts who have the job title of CEO**/
		return "[ {\"action\":\"getcondition\",\"filter\":\"2.CONTJOBTITLE=CEO\" } ]";
	}
}