I am trying to create property reference with lead standard objects with lead custom objects using variable as a property reference.
In lead objects, I have only link id named as contactid which is linked to custom objects table name as activity
I want this to be achieved ( $leadobjects.customobjectsPropertyName)
I want to parse entire lead database, using custom objects property name.
Please suggest how can I set variable in this case
Solved! Go to Solution.
I wan to create custom objects with default value zero.
You aren't "creating" Custom Objects in Velocity, only outputting them.
Custom Object records do not have a default value.
A Custom Object record has one or more properties. A property does not itself have a default value. The values "" (empty string) and null are valid, assignable (and useful) property values.
You may choose to consider "" and/or null as non-significant values from a output perspective, and to output a constant value instead:
#set( $DEFAULT_OUTPUT = 0 )
#foreach( $someObjectName in $someObjectList )
#if( $display.alt($someObjectName["somePropertyName"],"").isEmpty() )
${DEFAULT_OUTPUT}
#else
${someObjectName["somePropertyName"]}
#end
#end
The above code is still not changing the underlying property values in any way. You are merely choosing to output something special in certain cases.
I want to parse entire lead database, using custom objects property name.
I don't understand your phrasing. You can't parse "the entire lead database" in Velocity. When your code is run, you have access to the current Lead/Person object (the one being sent the email) and its linked Custom Object records. Not all Leads, nor all Custom Object records.
This expression $leadobjects.customobjectsPropertyName is basically meaningless. $leadobjects is not an object in Marketo's Velocity context; the singular $lead, which refers to the current Lead/Person record, is a built-in object (a LinkedHashMap to be precise).
And the properties of $lead are never properties of Custom Objects, not even of those COs records that are directly linked to the Lead. All properties of $lead are Lead-level properties (including segment membership, which is a property of the Lead).
And please, as noted before, don't try to "speak in code" if you're not a coder. Speak in business requirements. That's the only way to get useful help.
For the property custom objects I want to print default value set as 0. Because in email script token default value not working it display custom objects property tag as a token. Hence, please suggest what approach I need to apply or where should I start data parse in custom objects or lead objects to display default value 0.
For the property custom objects I want to print default value set as 0. But in email it display custom objects property tag as a token.
No idea what you mean by this.
I wan to create token as email script with default value zero.
defualt value for those lead/custom objects whose property is either not exists or null.
If this is incomplete statement then I can add only this details: - I have created custom objects with link id i.e. one to many mapping. I am using this custom objects data in email to display the data for one property total points in such a way that default value display zero always.
I wan to create custom objects with default value zero.
You aren't "creating" Custom Objects in Velocity, only outputting them.
Custom Object records do not have a default value.
A Custom Object record has one or more properties. A property does not itself have a default value. The values "" (empty string) and null are valid, assignable (and useful) property values.
You may choose to consider "" and/or null as non-significant values from a output perspective, and to output a constant value instead:
#set( $DEFAULT_OUTPUT = 0 )
#foreach( $someObjectName in $someObjectList )
#if( $display.alt($someObjectName["somePropertyName"],"").isEmpty() )
${DEFAULT_OUTPUT}
#else
${someObjectName["somePropertyName"]}
#end
#end
The above code is still not changing the underlying property values in any way. You are merely choosing to output something special in certain cases.
Hi San,
The code is working fine with condition but one minor issue i am facing.
It display blank not ZERO if there is no data. Can you please suggest again if anything need to change in above code?
Also, email delivery time is taking extra minutes here.
By "no data" do you actually mean "no records in the CO list"? If so, then say that.
Case-1 When there is data in CO it works fine.
Case-2 When the lead data is not having CO table it display blank
Please suggest for case-2 to display default value zero is possible or not.
Case-2 When the lead data is not having CO table it display blank
Not a table, a list. Again: precision. All these terms mean different things.
You can check if the list is empty and output a placeholder value accordingly.
#set( $DEFAULT_OUTPUT_NO_LIST = "No records in list." )
#set( $DEFAULT_OUTPUT_NO_PROPERTY = 0 )
#if( $someObjectList.isEmpty() )
${DEFAULT_OUTPUT_NO_LIST}
#else
#foreach( $someObjectName in $someObjectList )
#if( $display.alt($someObjectName["somePropertyName"],"").isEmpty() )
${$DEFAULT_OUTPUT_NO_PROPERTY}
#else
${someObjectName["somePropertyName"]}
#end
#end
#end