This article has been submitted by Ranjith. He is a Siebel certified consultant working on Siebel EAI.
Requirement:
Saving an exported file to the client machine running Internet explorer, allowing the user to choose the location. This called for a FileSaveAs dialog box popping up. After a lot of searching on the net, I found it could be done in Javascript with the help of following code:
Solution:
var File = "this is the data"
var objDialog =new ActiveXObject("SAFRCFileDlg.FileSave")
objDialog.FileName = “Filename”;
objDialog.FileType = "File File";
var intReturn = objDialog.OpenFileSaveDlg();
if(intReturn)
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var f1 = fso.CreateTextFile(objDialog.FileName, true,true);
// Write a File Hierarchy
f1.Write(File);
// Close the file.
f1.Close();
}
You can add this code in the browser script and see it in action.
Please Note (by Neel) : I personally tried this code and it seems that it only works on Windows XP OS. It seems Microsoft has deprecated SAFRCFileDlg.FileSave object and the library is not available in other operating systems except Windows XP.
Hope this helps.

(2 votes, average: 4 out of 5)
4 Comments at "File SaveAs Dialog box in Siebel"
Hi eel This is a very useful site keep up the good work was wondering if you could post a functional cum techical doc on Assignment manager.
Thanks once again for all you articles!!
During my work with Siebel I was forced to save exported data on client’s machine too. It can be done without the need for an ActiveXObject that I don’t like because you must allow it on client. Here is a function that saves a content into a file on client’s machine running IE:
function saveFile( content )
{
var w = window.frames.w;
if( !w ) {
w = document.createElement( ‘iframe’ );
w.id = ‘w’;
w.style.display = ‘none’;
document.body.insertBefore( w );
w = window.frames.w;
if( !w ) {
w = window.open( ”, ‘_temp’, ‘width=100,height=100′ );
if( !w ) {
window.alert( ‘Unable to create file!’ );
return false;
}
}
}
var d = w.document;
d.open( ‘text/plain’, ‘replace’ );
d.charset = ‘windows-1250′;
d.write( content );
d.close();
var name = ‘batchExport.txt’;
var saved = false;
while (!saved) {
if( d.execCommand( ‘SaveAs’, null, name ) ){
saved = true;
} else {
window.alert(’File was not saved!’);
}
}
w.close();
return false;
}
Weird, I was trying to post a solution without ActiveX and my comment jus didn’t submit.
Hi Ranjith, this is Mohan. ur post is Very useful to me. Plase mail me ur mail id. My mail id is mohan.sieb@gmail.com
Comment Now!