I am able to add a context variable to an existing...
# suitecommerce
k
I am able to add a context variable to an existing view within addChildViews…. is that considered bad practice? seems like a good way to add context for specific functionality
s
Is there a reason not to use
addToViewContextDefinition
?
k
yes - that is what Im using, but it only gets added if the child view gets added…. so its pdp.addChildViews( pdp.PDP_FULL_VIEW …. pdp.addToViewContextDefinition the child view gets added under a certain condition and the context gets added
s
Copy code
if (someCondition) {
  pdp.addChildViews(...);
  pdp.addToViewContextDefinition(...);
}
or
Copy code
if (someCondition) {
  pdp.addChildViews(...
    pdp.addToViewContextDefinition(...);
  );
}
?
Is that what you're saying?
OK, I don't think there's anything wrong with that other than just being a bit odd 😄
k
sorry - trying to edit this and its not making any sense
the if condition is within the add child views so I can get the pdp info…then either add the child view and change the context or just return nothing
pdp.getItemInfo() doesnt return anything unless you’re within one of the methods