OnSaveRequest stringObj.replace();

K

kookie

I am using several form fields to name my file on save. the fields contain
blank spaces. I want to remove these space, but i cant figure out the syntax.
I have tried
replace(" ", "");
replace(/\'/g, "''");
replace(/'/g, "''");

Please help!
 
K

kookie

You look hard and long enough eventually you figure it out. here is the
solution.

var strMnPName =
XDocument.DOM.selectSingleNode("/my:myFields/my:MnPName").text;
var strRegion =
XDocument.DOM.selectSingleNode("/my:myFields/my:Region").text;
var strRole = XDocument.DOM.selectSingleNode("/my:myFields/my:Role").text;

var blank = " ";
//strMnPName = strMnPName.replace(blank,""); // this only removed the
first space

var nameSum = countSpaces(strMnPName); // by counting spaces I was able
to remove all
for(var icount = 0; icount < nameSum; icount++) {
strMnPName = strMnPName.replace(blank,"");

}
var roleSum = countSpaces(strRole);
for(var icount = 0; icount < roleSum; icount++) {
strRole = strRole.replace(blank,"");

}
//XDocument.UI.Alert(countSpaces(strMnPName));


var strURI = XDocument.Solution.URI; //template path
var strFormLib = strURI.substr(0, strURI.indexOf("Forms/template.xsn"));

if (XDocument.IsNew == true || eventObj.IsSaveAs == false)
{
if (eventObj.IsSaveAs == true)
{
XDocument.UI.SetSaveAsDialogLocation(strFormLib);
XDocument.UI.SetSaveAsDialogFileName(strMnPName + "_" +
strRegion + "_" + strRole);
}
eventObj.IsCancelled = eventObj.PerformSaveOperation();
eventObj.ReturnStatus = true;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top