Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
Datasource callback function is not getting correct values
Venus00
Hi All,
I am facing a big problem while using datasource (using FormAPI) to populate the dropdowns in various DCTs.
Starange thing datasources are failing only for non-inline call to datasource.
Although based on the logs of Datasource java classes, correct option map is being returned but somehow the callback function is not getting the those options.
is there anything comes between java return and callback method in js ??
Below is my JS methods:
function initBrandCodeField(itemName){
var dsObj = new IWDatasource();
var dsParams = new IWMap();
var returnParams = new IWMap();
returnParams.put("itemXPath", itemName);
dsObj.executeDatasource("setBrandCode", "BrandNameGlobalWeb", dsParams, returnParams);
}
function setBrandCode(options, returnParams){
//alert("testing" + options); // getting blank as "options" value
var workarea_path=IWDatacapture.getWorkarea ();
var brand_name = workarea_path.match(/.*\/default\/main\/(.+?)\/.*/)[1];
var keys = options.keys();
// alert(keys);
var xpath = returnParams.get("itemXPath");
// alert(keys);
var item = IWDatacapture.getItem(xpath);
// alert(item.getValue());
for(var i=0; i if(options.get(keys
).replace(/\s+/,'') == brand_name){
item.setValue(keys
);
}
}
}
Find more posts tagged with
Comments
jbonifaci
At a high level your code looks ok.
You realize of course that you aren't trying to set the options for the item anywhere, right? If you just didn't include this code, please do include it. If you don't have this code, you probably need to add it,
.
~Jeff
Venus00
Thanks for your respose.
yeah i am using this datasource just to get the list of available brands. and comparing it with the current value that i already have.
but the problem is, "options" variable is not being populated with the list of values returned from java program. On alert, it is just showing blank even though java program is returning all values.
jbonifaci
Your code is perfectly fine, up until your "alert("testing" + options);" line. Assuming this is uncommented, it should alert "testing[object Object]". You have several things wrong with your code after this line, including at least one thing that would throw a javascript error and cause your javascript not to execute at all. If you get rid of everything else other than the first alert in your setBrandCode function, the alert should work as I stated above.
If it doesn't, then you're either not posting your actual code (likely, since it doesn't even compile), or your datasource doesn't actually work with the parameter you are passing it.
~Jeff
Venus00
The problem was because of datasourceJs.jsp and dcapi_datasource.js inside IW_HOME/local/config/lib/content_center/customer_src/web/datacapture/ .
There was some mismatching of the separator used indise those files.