• Test User 153
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
I am uploading a document and attaching it to a case using Javascript. Till this point it is working fine. But when I am trying to send the parameter ( CASE ID) using Action function and even though the function is getting called the caseId is not sent through... PFB the code...

<apex:page standardController="Case" extensions="InputfileUploadCont">
<script type="text/javascript">
var __sfdcSessionId = '{!GETSESSIONID()}';

function uploadFile()

var input = document.getElementById('file-input');
// var parentId = "500g0000004UEb2" ;
var caseId;
var filesToUpload = input.files;

for(var i = 0, f; f = filesToUpload[i]; i++)
{
var reader = new FileReader();

// Keep a reference to the File in the FileReader so it can be accessed in callbacks
reader.file = f;

reader.onerror = function(e) 
{
switch(e.target.error.code) 
{
case e.target.error.NOT_FOUND_ERR:
alert('File Not Found!');
break;
case e.target.error.NOT_READABLE_ERR:
alert('File is not readable');
break;
case e.target.error.ABORT_ERR:
break; // noop
default:
alert('An error occurred reading this file.');
};
};

reader.onabort = function(e) 
{
alert('File read cancelled');
};

reader.onload = function(e) 
{
var newRecords = [];

var newCase = new sforce.SObject("Case");
newCase.Case_Language__c = "Russian";
newCase.subject = document.getElementById("subject");
newRecords.push(newCase);
var resultCase = sforce.connection.create(newRecords);
if(resultCase [0].getBoolean("success")){
alert('case created' + resultCase[0].id);

}else{
alert('Could not create record '+result);
}

var att = new sforce.SObject("Attachment");
att.Name = this.file.name;
att.ContentType = this.file.type;
att.ParentId = resultCase[0].id;

att.Body = (new sforce.Base64Binary(e.target.result)).toString();

sforce.connection.create([att],
{
onSuccess : function(result, source) 
{
if (result[0].getBoolean("success")) 
{
alert('Done : ' + resultCase[0].id);
var a = resultCase[0].Id
updateCase(a);
console.log("new attachment created with id " + result[0].id); 

else 
{
console.log("failed to create attachment " + result[0]);
}
}, 
onFailure : function(error, source) 
{
console.log("An error has occurred " + error);
}
});
};

reader.readAsBinaryString(f);

}
}
</script>
<script src="/soap/ajax/29.0/connection.js" type="text/javascript"></script>

<apex:form >
<input id="file-input" type="file" name="file"/>
<input type="button" value="Upload" onclick="uploadFile();" />

<apex:actionFunction name="updateCase" action="{!updateCase}" reRender="txt" >
<apex:param name="scaseId" assignTo="{!updatedCaseId}" value="" />
</apex:actionFunction>

<b><apex:outputLabel value="{!val}" id ="txt"/></b>

</apex:form> 
</apex:page>

CONTROLLER

public with sharing class InputfileUploadCont{

public Id updatedCaseId {get; set;}
public String val{get;set;}

public InputfileUploadCont(ApexPages.StandardController controller) {}

public void updateCase(){
val = 'Case ID : - ' + updatedCaseId;
system.debug('Case ID : - ' + updatedCaseId);
system.debug('scaseId Case ID : - ' + Apexpages.currentPage().getParameters().get('scaseId'));
system.debug('updatedCaseId Case ID : - ' + Apexpages.currentPage().getParameters().get('updatedCaseId'));
}
}
On the click of title it navigates to the next page, i want to have a behaviour like javascript hide/show buttons. But I am not able to achieve so.

I tried with Iframes as well, but then only one '' be shown at a time . Please suggest how can I fix the issue,

I have to query test__c using the following query

SELECT test__c, Summary FROM FAQ__kav where PublishStatus =: 'Online' AND Language =: 'en_US' AND ArticleNumber =: '000001007' Limit 1];

 
<apex:page sidebar="false" title="Article List">
<style>
td{
vertical-align : top;
text-align: left;
}
</style>
<apex:form >
<apex:pageBlock title="Article List" >
<apex:panelGrid width="100%">
<table width="99%">
<tr>
<th width="33%">Title</th>
<th width="33%">Article Type</th>
<th width="33%">Summary</th>
</tr>
</table>
<knowledge:articleList articleVar="article" hasMoreVar="false" pageSize="10">
<table width="99%">
<tr>
<td width="33%">
<apex:outputLink target="_blank" value="{!URLFOR($Action.KnowledgeArticle.View,
article.id,['popup' = 'true'])}">{!article.title}</apex:outputLink>
</td>
<td width="33%"><apex:outputText >{!article.articleTypeLabel}</apex:outputText></td>

<td width="33%"><apex:outputText >{!article.abstract}</apex:outputText></td>
</tr>
</table>
</knowledge:articleList>
</apex:panelGrid>
</apex:pageBlock>
</apex:form>
</apex:page>

 

Has anyone embedded video in the new Knowledge Base app?  I found an idea related to it, so I'm guessing it's not possible through the delivered article managment UI where the end user could easily embed the video themselves.  I'm sure it's possible with VF, but haven't seen anyone else who has done it.

 

Here's the link to the idea:  Embed Video in Knowledge Base