• Eric An
  • NEWBIE
  • 29 Points
  • Member since 2017

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 8
    Replies
So I have this Command command button on a inline visual force page. 

 
<apex:commandButton id="urlButton" title="Send selected file(s) to MCA" value="Send selected file(s) to MCA" onclick="SendObject();return false;"/>
  <apex:commandButton id="sendurlbutton" title="Send to MCA with Docs" value="Send to MCA with Docs" onclick="generateUrls();return false;"/>
  </apex:form>
it calls the function generateUrls, the function is:
 
function generateUrls()
    {
        var isSelected = false;
        var inputElem = document.getElementsByTagName("input");
        var selectedIds = new Array();
        for(var i=0; i<inputElem.length; i++)
        {   
            if(inputElem[i].id.indexOf('checkedone')!=-1)
            {
                if(inputElem[i].checked)
                {
                    var checkedElement = document.getElementById(inputElem[i].id);
                    var closedTr = $j(checkedElement).closest('tr');
                    var menuForSelectedItem = $j(closedTr).find(".menubutton");
                    if(menuForSelectedItem)
                    {
                        selectedIds.push($j(menuForSelectedItem).attr('id').split('_')[1]);
                    }
                }
            }       
        }
        if(selectedIds.length == 0)
        {
            alert('Please select a file(s) before uploading!');
        }
        else
        {   
            var htmlText = '<div style="margin-bottom:10px;"><strong>Sending selected file(s) to MCA.</strong></div><div>Please wait for file status to appear...</div>';
            var dlg = $j('<div title="MCA File Upload Status..." />').html(htmlText).dialog({ width: 500, height: 250 });
            
            Visualforce.remoting.Manager.invokeAction(
            '{!$RemoteAction.GenerateUrlExtension.submitDocumentsToMCA}',
            selectedIds, 
            '{!MCA_Submission__c.Opportunity__c}', 
            '{!MCA_Submission__c.id}',
            '{!MCA_Submission__c.App_Id__c}',
            function(result, event){
                var updateText;
                if (event.status) {
                    updateText = '<div><strong>Upload Results:</strong></div><ul>';
                    for(var i=0; i < result.length; i++) {
                        updateText += '<li style="margin-bottom:10px;">' + result[i] + '</li>';
                    }
                    updateText += '</ul><div><strong>Process Complete.</strong></div>';
                    dlg.html(updateText);
                } else if (event.type === 'exception') {
                    alert('Exception' + event.message); 
                } else {
                    alert('Error' + event.message); 
                }
            }, 
            {escape: true}
        );

 So I have a custom button, and I'm trying to execute the same method however I'm not sure how I can get the attachmentids in a custom button. My question is it is possible? What am I missing. Here is what I am trying...
 
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/26.0/apex.js")}

var mca_id = "{!MCA_Submission__c.Id}";
var app_id = "{!MCA_Submission__c.App_ID__c}";
var sub_id = "{!MCA_Submission__c.Opportunity__c}";




var upload = sforce.apex.execute("GenerateUrlExtension","submitDocumentsToMCA",{sub_id,mca_id,app_id,  });



alert("Result: " + mca_request + upload);
document.location.reload(true);

in a custom button. I'm just not sure how to get the attach ment Ids in a var and then to the method. 
trigger DeDupeLead on Lead (before insert)

 {  //get the data quality queue record            
     GROUP DataQualityGroup = [SELECT Id 
                                       FROM GROUP
                                       WHERE DeveloperName= 'Data_Quality'
                                       LIMIT 1];
    for(Lead myLead:Trigger.new) {
            
        //Searching for matchingContacts

        List<Contact> matchingContacts = [SELECT Id
                                       FROM Contact
                                       WHERE Email = :myLead.Email];

         System.debug (matchingContacts.size() + 'contact(s) Found.');

        //If MatchingContacts Found...

        If (!matchingContacts.isEmpty()) {
        //Assign the lead to Data quality queue

        myLead.OwnerId  = DataQualityGroup.Id;

        
        //Add the dupe contacts Ids into lead descriptons

        String dupeContactMessages = 'Duplicate Contacts Found: \n';
        for( Contact matchingContact : matchingContacts) {
         dupeContactMessages += matchingContact.FirstName +''
                               +matchingContact.LastName + ''
                               +matchingContact.Account.Name +''
                               +matchingContact.Id; 
    }
    myLead.Description = dupeContactMessages + '\n'+ myLead.Description;
    }

    }
    }
 
Below Example after taking Account als its throwing same error where i'm wrong let me know any one help in that 


trigger con_accname_error on Contact (before insert,before update) {
    for(contact c:trigger.new){
        if(c.Account==null){
            c.addError('pl enter account name');
        }
       
        
    }

}

 
So I have this Command command button on a inline visual force page. 

 
<apex:commandButton id="urlButton" title="Send selected file(s) to MCA" value="Send selected file(s) to MCA" onclick="SendObject();return false;"/>
  <apex:commandButton id="sendurlbutton" title="Send to MCA with Docs" value="Send to MCA with Docs" onclick="generateUrls();return false;"/>
  </apex:form>
it calls the function generateUrls, the function is:
 
function generateUrls()
    {
        var isSelected = false;
        var inputElem = document.getElementsByTagName("input");
        var selectedIds = new Array();
        for(var i=0; i<inputElem.length; i++)
        {   
            if(inputElem[i].id.indexOf('checkedone')!=-1)
            {
                if(inputElem[i].checked)
                {
                    var checkedElement = document.getElementById(inputElem[i].id);
                    var closedTr = $j(checkedElement).closest('tr');
                    var menuForSelectedItem = $j(closedTr).find(".menubutton");
                    if(menuForSelectedItem)
                    {
                        selectedIds.push($j(menuForSelectedItem).attr('id').split('_')[1]);
                    }
                }
            }       
        }
        if(selectedIds.length == 0)
        {
            alert('Please select a file(s) before uploading!');
        }
        else
        {   
            var htmlText = '<div style="margin-bottom:10px;"><strong>Sending selected file(s) to MCA.</strong></div><div>Please wait for file status to appear...</div>';
            var dlg = $j('<div title="MCA File Upload Status..." />').html(htmlText).dialog({ width: 500, height: 250 });
            
            Visualforce.remoting.Manager.invokeAction(
            '{!$RemoteAction.GenerateUrlExtension.submitDocumentsToMCA}',
            selectedIds, 
            '{!MCA_Submission__c.Opportunity__c}', 
            '{!MCA_Submission__c.id}',
            '{!MCA_Submission__c.App_Id__c}',
            function(result, event){
                var updateText;
                if (event.status) {
                    updateText = '<div><strong>Upload Results:</strong></div><ul>';
                    for(var i=0; i < result.length; i++) {
                        updateText += '<li style="margin-bottom:10px;">' + result[i] + '</li>';
                    }
                    updateText += '</ul><div><strong>Process Complete.</strong></div>';
                    dlg.html(updateText);
                } else if (event.type === 'exception') {
                    alert('Exception' + event.message); 
                } else {
                    alert('Error' + event.message); 
                }
            }, 
            {escape: true}
        );

 So I have a custom button, and I'm trying to execute the same method however I'm not sure how I can get the attachmentids in a custom button. My question is it is possible? What am I missing. Here is what I am trying...
 
{!REQUIRESCRIPT("/soap/ajax/26.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/26.0/apex.js")}

var mca_id = "{!MCA_Submission__c.Id}";
var app_id = "{!MCA_Submission__c.App_ID__c}";
var sub_id = "{!MCA_Submission__c.Opportunity__c}";




var upload = sforce.apex.execute("GenerateUrlExtension","submitDocumentsToMCA",{sub_id,mca_id,app_id,  });



alert("Result: " + mca_request + upload);
document.location.reload(true);

in a custom button. I'm just not sure how to get the attach ment Ids in a var and then to the method. 
Hi,

I am having this code under Custom button click ffor case record and it works fine in Sales Cloud but the same code is not working as expected in service console(redirection to Case owner change page doesnt happen)

{!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")} 
{!REQUIRESCRIPT("/support/console/29.0/integration.js")} 

var recId = window.location.href.substring(window.location.href.lastIndexOf('/') + 1); 
var c = new sforce.SObject("Case"); 
c.id = "{!Case.Id}"; 

// make the field change 
//c.Agent_Handover_From__c= '{!$User.Id}'; 
c.Agent_Handover_From__c= '{!$User.FirstName}'+ ' ' + '{!$User.LastName}'; 
//{!$User.FirstName} {!$User.LastName}"; 
c.Agent_Handover_Time__c = new Date(); 
c.Stage__c='Sales HandOver'; 
c.RecordTypeId ='01290000000iaw4'; 
// save the change 
sforce.connection.update([c]); 
var redirectURL = '/'+ recId + '/' + 'a?retURL=%2F' + recId ; 
//window.location = '/'+ recId + '/' + 'a?retURL=%2F' + recId ; 
if (sforce.console.isInConsole()) { 
sforce.console.getEnclosingTabId(function(enclosingResult){ 
sforce.console.getEnclosingPrimaryTabId(function(primaryResult){ 
sforce.console.openSubtab(primaryResult.id, redirectURL, true, '', null); 
}); 
}); 

else { 
window.location.href = redirectURL; 
}

Can you please suggest the change in the code to make it work in service console.


Regards
Srikanth Sunkara
It works in prodction but not in sanbox (acsess token is not required)
  • November 08, 2017
  • Like
  • 0
We are trying to create a connection between two salesforce orgs through API. What we are looking for exactly is to integrate two orgs so that when we update a field or object on one org it automatically updates on the second org and vice versa I have limited to no coding experience so dont really have a clue where to go to get the data to integrate. Any assistance would be extremely appreciated - note we have tried Salesforce to Salesforce but its limitations do not work for us - having to externally share each record manually and the fact when you delete on one org it does not delete on the other.
Hi,

We are running into some issues with a Lead integration via REST API.
The client is connecting via Forcedotcom .NET SDK and when trying to update a record,
it's receiveing the following message:

"Json Deserialization failed on token 'null' and has left off in the middle of parsing a row. Will go to end of row to begin parsing the next row"

We're not beeing able to collect any log inside Salesforce, so I think the API is blocking
the entire request since it appears to be mal formed. Anyone had a similiar issue?
gracias Sr.
I am going to this url (with id and secrets changed):

https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&client_secret=999999999999999999999&scope=full%20refresh_token&redirect_uri=https://dev.gcast.com.au/Core/Integration/IntegrationLogin.aspx&state=sfdc&prompt=login%20consent

And I get this error:

error=redirect_uri_mismatch&error_description=redirect_uri%20must%20match%20configuration

The callback url in my app is:

https://dev.gcast.com.au/Core/Integration/IntegrationLogin.aspx&state=sfdc&prompt=login%20consent

Can anybody see where I am going wrong?