Below is the script added to a non-auto generated section. This section is embedded in the section where the function(searchID) is invoked on a button click.
<script>
function searchID(){
var sURL = new SafeURL("Data-Portal.ActivityName");
sURL.put("pzPrimaryPageName","pyDisplayHarness");
var callback={
success : function(oResponse)
{
var strResponse = oResponse.responseText;
if (strResponse == "error"){
pega.u.d.reloadSection(pega.u.d.getSectionByName("SearchSection","",""),"","",false,true,'-1',false);
}else if (strResponse == "CreateNewWO"){
createNewWork ('ClassName','', 'FlowName');
}
},
failure:function(oResponse){
}
};
var request = pega.util.Connect.asyncRequest('GET',sURL.toURL(),callback);
pega.util.Connect.handleReadyState(request,callback);
}
</script>