• mariappangomathiraj
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 16
    Replies
How to resolve this issue when using streaming API ?

My page code example:


<apex:page id="PG" controller="StreamingAPIController1"> <apex:form id="FRM"> <apex:includeScript value="{!$Resource.Comedy1}"/> <apex:includeScript value="{!$Resource.Jquery}"/> <apex:includeScript value="{!$Resource.Json2}"/> <apex:includeScript value="{!$Resource.jquery_cometd}"/> <apex:actionFunction name="GetRefreshedAccounts" reRender="PB,PBT"/> <script type="text/javascript"> (function($) { $(document).ready(function() { // Connect to the CometD endpoint $.cometd.init({ url: window.location.protocol+'//'+window.location.hostname+'/cometd/24.0/', requestHeaders: { Authorization: 'OAuth {!$Api.Session_ID}'} }); // Subscribe to a topic. JSON-encoded update will be returned in the callback // In this example we are using this only to track the generated event $.cometd.subscribe('/topic/RefreshAccounts', function(message) { //You can use message as it will return you many attributes //I am just using to track that event is generated GetRefreshedAccounts(); }); }); })(jQuery) </script> <apex:pageBlock id="PB"> <apex:variable var="count" value="{!0}" /> <apex:pageBlockTable id="PBT" value="{!getRefreshedAccount}" var="AllAcc"> <apex:column headerValue="S.No."> <apex:variable var="count" value="{!count+1}" /> {!count} </apex:column> <apex:column value="{!AllAcc.Name}" headerValue="Name"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>


My controller Code:
public class StreamingAPIController1  
{  
    //Everytime page is reRendered it will get refreshed values of account  
    public List<Account> getRefreshedAccount  
    {  
        get  
        {  
            return [select Id, Name from Account LIMIT 50000] ;  
        }  
        set;  
    }  
      
    public StreamingAPIController1()  
    {  
    }  
}

Push topic code:

PushTopic pushTopic = new PushTopic();  
pushTopic.Name = 'RefreshAccounts';  
pushTopic.Query = 'SELECT Id, Name FROM Account';  
pushTopic.ApiVersion = 33.0;  
pushTopic.NotifyForFields = 'All';  
insert pushTopic;  


Please help to resolve this issue.. I have created Account record,but it haven't replicated in Streaming page.
 

string s = '|'+'Test';
system.debug(Logginglevel.ERROR,'::::s3:::::::'+s);

 

Output:

::::s3:::::::&#124;Test

 

Expected Output:

::::s3:::::::    |Test

 Is it possible to get the above output?

My code:

ss= (ss!= '' && ss!= null) ? ss.replaceAll('[$^]','[$|^]') : '';

 

My input:

^Hospitality$^Hospitality$^Industrial / Office Flex$^Industrial$^Industrial Condos$^Industrial/Warehouse$^Hospitality$

 

I got the following error:

 

Illegal group reference (Invalid replacement string: '[$|^]'. '$' should be escaped if you do not intend to use a backreference. Try using Matcher.quoteReplacement() for your argument)

 

I am using matcher 

 

Pattern nonWordChar = Pattern.compile('[\\$|^]');
ss = nonWordChar.matcher(ss).replaceAll('');

 

But its not working

 

I am using remote action method to call the method from script.But its not working.

 

Here is my code:

 

VF page:

<apex:page controller="remotingController" sidebar="false" showHeader="false" standardStylesheets="false">
<apex:includescript value="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"/>

<script>
function Save(){
var textvalue = $('.texts').text();
remotingController.renameAlert(textvalue);
return false;
}
</script>

<apex:form >
<div class = "position">
<apex:outputLabel value="TextInput"></apex:outputLabel>
<apex:inputText styleclass = "texts" style="margin-left:30px;" />
<button onclick="Save();">Save </button>
</div>
</apex:form>
</apex:page>

 

Class:

global without sharing class remotingController  {
    public remotingController(){
    }
    
  @RemoteAction  
   global static void  renameAlert(string text){ 
       system.debug(':::::::text:::::::::::');
   }

}

 

 

I have 100 accounts.I am forming one map with following values.

 

Map<String,String> accounts = new Map<String,String>();

for(Account a : AccountList){

string accountIds = a.Id+'str';

accounts.put(accountIds,a.Name)

}

 

I am using this map in inside of JS function.

 

JS code:

 $(document).ready(function() {

<apex:repeat value="{!AccountList}" var="acct">

 

var CRE = accountId+'str';

var Mapvalue = '{!accounts['+CRE+']}';
console.log('::::::::CRE:::::::'+CRE);

<apex:repeat/>

});

 

I am getting the below error:

 

Map key +CRE+ not found in map

Error is in expression '{!Mapvalue['+CRE+']}' in component <apex:repeat> in page accountsearch
 
Is any one help to get this value of Key(AccountId + string value)?

 

String Names = '^Community$|^Luxury$|^Golf$|^Course$|^Hospitality$|^Industrial$|^';

 

 

 

My Code:

 

Names = (Names!= '' && Names!= null) ? Names.replaceAll('\\$|^,'') : '';
system.debug(Logginglevel.Info,'::::Names::::::::::'+Names);

 

Current output in Debug Log:

^Community$&#124;^Luxury$&#124;^Golf$&#124;^Course$&#124;^Hospitality$&#124;^Industrial$&#124;^Industrial$&#124;

 

Expected  Output:

 

Community,Luxury,Golf,Course,Hospitality,Industrial 

 

I have inserted the FeedItem in trigger(after update).But i got the following exception.

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Entity is read-only: FeedItem: 

 

I have enabled Enable option in Chatter Settings.Can any one help to solve this above DML exception in Trigger?

I have added some ApexPages.Message in My controller.Its running in unauthenticated site(Guest User).I have added one ApexPages.Message in constructor.And other messages in One method.But Only constructor ApexPages.Message showing in the VF page.Method ApexPages.Message didn't showi in that page.

 

In the debug logs error message is displaying but in the visual force page it is not showing.

Always its goto unauthorized page.Please help.

 

My page code :

<apex:page controller="updateContact" showHeader="false" sidebar="false" standardStylesheets="false">


<apex:form Id="Contact_update" forceSSL="true">

<apex:pageMessages/>

<div class = "updateButtonDiv">
<apex:commandbutton action="{!registerUsers}" rerender="Contact_update"/>
</div>
</apex:form>

</apex:page>

 

My controller code :

 

public class updateContact {

public string contactId;
public Contact contact {get;set;}

public updateContact() {

contactId= ApexPages.currentPage().getParameters().get('conatctid');
try{
contact = [select Id,email from contact where id=:contactId];
}
catch(Exception e){
// hasError = true;
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.FATAL,'No Contact ID was passed to this form so your contact information cannot be updated. '+contactId);
ApexPages.addMessage(myMsg);
System.debug(':::::::::::::::::::::Error: '+e.getMessage());
return;
}
}

public PageReference registerUsers() {
try{
if (!checkEmail()) {
ApexPages.Message msg = new ApexPages.Message(ApexPages.Severity.ERROR, 'That email already exists.');
ApexPages.addMessage(msg);
system.debug('::::msg::::::::::::::'+msg);
return null;
}
catch(Exception e) {
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Internal server error. '+e));
}
return null;
}


// check if this username alredy exists
private boolean checkEmail() {
List<User> uList = [select id from User where username =: contact.email ];
return uList.isEmpty();
}
}

 

How to avoid the new contact creation in Site.createPortalUser(u, accountId, null);Because I have the contact.I don't need to create a new one.I am updating the existing contact to the creating portal user.Is it possible?

 

My code:

 

contactId= ApexPages.currentPage().getParameters().get('conatctid');

 

Contact c = [Select c.Update_Information__c, c.Top_Investor__c, c.Top_Account__c,
c.Title, c.Temporary_Email__c, c.Tags__c, c.SystemModstamp, c.Starred__c, c.Seller__c, c.Salutation, c.Residential_Subcategory__c,
c.ReportsToId, c.Regional_Interest_s__c, c.Phone, c.OwnerId, c.Other_Geographic_Preference__c, c.OtherStreet
From Contact c
WHERE id = :contactId];

 

private User createUsers(){
User u = new User();
u.FirstName = firstName;
u.LastName = lastName ;
u.companyName = CompanyName;
u.Email = email;
u.Username = email;
if (email.length() > 40)
u.CommunityNickname = email.substring(0,39);
else
u.CommunityNickname = email;
u.FederationIdentifier = email;
u.ShareFile_Password__c = sfPassword;
u.ContactId = contact.Id;
return u;
}

 

Account acc = new Account(Name = CompanyName);
acc.ownerId = ownerId;
insert acc;
system.debug('::::acc:::::::::::::'+acc);
accountId = acc.id;

 

String userId = Site.createPortalUser(u, accountId, null);

 

But this code generate the new contact for newly created portal user.How to avoid the new contact create?How to assign the existing contact to this newly created portal user?

I am writing test class for below code:

 

Global class OpportunityController{
public OpportunityController(ApexPages.StandardController controller) {
oppList = New List<Opportunity>();
op = (Opportunity )controller.getRecord();
System.debug('op----'+op);
System.debug('opPayment_Terms__c ----'+op.Payment_Terms__c );
System.debug('opId----'+op.Id);
oppList = [SELECT Name,Payment_Terms__c,Account.BillingCountry,(SELECT Margin__c FROM OpportunityLineItems) FROM Opportunity WHERE Id =: op.Id];
System.debug('oppList ----------'+oppList );
System.debug('oppListPayment_Terms__c ----------'+oppList[0].Payment_Terms__c );
}

 

 

Test class code :

 

static testMethod void OpportunityController2() {
Account acc = new Account(Name='Testing1',BillingCountry='USA');
insert acc;

System.debug('::::::acc::::::::::'+acc); 
Opportunity opp = new Opportunity(Name='Test Opp4',AccountId=acc.Id,
Payment_Terms__c = 'testing 60',CloseDate=System.today().addMonths(1),StageName='Negotiations');
insert opp;

System.debug('::::::opp::::::::::'+opp); 
System.debug('::::::opp.Payment_Terms__c:::::::::::'+opp.Payment_Terms__c);
OpportunityController controller1 = new OpportunityController(new ApexPages.StandardController(opp));

}

 

In that Test code I have inserted one Opportunity with Payment_Terms__c field value.I am running the test method I got the following output:

 

:::::::acc::::::::::Account:{Name=Testing1, BillingCountry=South Africa, Id=001S000000cqIbiIAE}:
:::::opp:::::::::::Opportunity:{Name=Test Opp4, StageName=Negotiations, Payment_Terms__c=testing 60 days, AccountId=001S000000cqIbiIAE, Id=006S0000006dj9hIAA, CloseDate=2013-04-15 00:00:00}
::::::opp.Payment_Terms__c:::::::::::testing 60 days

 

Original class output:

 

oppList ----------(Opportunity:{Name=Test Opp4, AccountId=001S000000cqIbiIAE, Total_List_Price__c=0.00, Is_Step2_Required__c=false, Id=006S0000006dj9hIAA, Total_Discount__c=0.00})
opportunity.Payment_Terms__c ----------null

 

In original class code Payment_Terms__c field always shows null value.But I have inserted Payment_Terms__c value in Test class.I noticed in debug log  i.e  Payment_Terms__c field values didn't add in the oppList.Is any one help to get the Payment_Terms__c value in Original class?

Is anyone help to get the output for Below code? Some Encoding and decoding problem in my data.

 

My output::

 

/SMS/Homepage

 

My code:

String url = 'https://developer-edition.na9.force.com/MMMS/sitelogin?goto=%2Fapex%2FUnauthorized%3FstartURL%3D%252FSMS%252FHomepage';
System.debug(':::::::::url::::'+url);
url = url.substringAfter('startURL');
String encoded = EncodingUtil.urlEncode(url, 'UTF-8');
System.debug(':::::::::encodedData&colon;:::::::::'+encoded);
String decoded = EncodingUtil.urlDecode(encoded, 'UTF-8');
System.debug(':::::::::decodeddata&colon;:::::::::'+decoded);


::::::::url::::https://developer-edition.na9.force.com/MMMS/sitelogin?goto=%2Fapex%2FUnauthorized%3FstartURL%3D%252FSMS%252FHomepage
:::::::::encodedData&colon;:::::::::%253D%25252FSMS%25252FHomepage
::::::::decodeddata&colon;:::::::::%3D%252FSMS%252FHomepage

Any one working on Jquery standard validation plugin in VF pages?Please post the code for my reference.I have included this plugin my page but its not working.

I have worked for user friendly webpages using CSS printing styles.In that pages,I want  to breaks the pages(one pages to multiple pages).I have tried But its not works.Can Anyone post some code for pagebreaks in user friendly webpages(Links also didn't works)?

 

I used <apex:detail>  tag to display my account View and edit page...In page layout I tick both (Display Section Header On option in Section properties)Detail Page and Edit Page option in section properties.... I added Account fields and section header fields in page layout.... I view the page " header Section names not display in the view page" but I am editing  the page the header section names are displayed... Can I possible to display section header names in view page?

I have used Standard set controller to query the accounts object.... Accounts object have more than 4000 records..... i am passing the list to page the standard set controller pass only 2000 records....if any possible to pass all 4000 records to my visual force page....????????

hai......... if u have any possible to check the values of rich text area is null or not in any standard or costom object?

I am using remote action method to call the method from script.But its not working.

 

Here is my code:

 

VF page:

<apex:page controller="remotingController" sidebar="false" showHeader="false" standardStylesheets="false">
<apex:includescript value="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"/>

<script>
function Save(){
var textvalue = $('.texts').text();
remotingController.renameAlert(textvalue);
return false;
}
</script>

<apex:form >
<div class = "position">
<apex:outputLabel value="TextInput"></apex:outputLabel>
<apex:inputText styleclass = "texts" style="margin-left:30px;" />
<button onclick="Save();">Save </button>
</div>
</apex:form>
</apex:page>

 

Class:

global without sharing class remotingController  {
    public remotingController(){
    }
    
  @RemoteAction  
   global static void  renameAlert(string text){ 
       system.debug(':::::::text:::::::::::');
   }

}

 

 

I have 100 accounts.I am forming one map with following values.

 

Map<String,String> accounts = new Map<String,String>();

for(Account a : AccountList){

string accountIds = a.Id+'str';

accounts.put(accountIds,a.Name)

}

 

I am using this map in inside of JS function.

 

JS code:

 $(document).ready(function() {

<apex:repeat value="{!AccountList}" var="acct">

 

var CRE = accountId+'str';

var Mapvalue = '{!accounts['+CRE+']}';
console.log('::::::::CRE:::::::'+CRE);

<apex:repeat/>

});

 

I am getting the below error:

 

Map key +CRE+ not found in map

Error is in expression '{!Mapvalue['+CRE+']}' in component <apex:repeat> in page accountsearch
 
Is any one help to get this value of Key(AccountId + string value)?

 

I have inserted the FeedItem in trigger(after update).But i got the following exception.

 

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Entity is read-only: FeedItem: 

 

I have enabled Enable option in Chatter Settings.Can any one help to solve this above DML exception in Trigger?

Is anyone help to get the output for Below code? Some Encoding and decoding problem in my data.

 

My output::

 

/SMS/Homepage

 

My code:

String url = 'https://developer-edition.na9.force.com/MMMS/sitelogin?goto=%2Fapex%2FUnauthorized%3FstartURL%3D%252FSMS%252FHomepage';
System.debug(':::::::::url::::'+url);
url = url.substringAfter('startURL');
String encoded = EncodingUtil.urlEncode(url, 'UTF-8');
System.debug(':::::::::encodedData&colon;:::::::::'+encoded);
String decoded = EncodingUtil.urlDecode(encoded, 'UTF-8');
System.debug(':::::::::decodeddata&colon;:::::::::'+decoded);


::::::::url::::https://developer-edition.na9.force.com/MMMS/sitelogin?goto=%2Fapex%2FUnauthorized%3FstartURL%3D%252FSMS%252FHomepage
:::::::::encodedData&colon;:::::::::%253D%25252FSMS%25252FHomepage
::::::::decodeddata&colon;:::::::::%3D%252FSMS%252FHomepage

I used <apex:detail>  tag to display my account View and edit page...In page layout I tick both (Display Section Header On option in Section properties)Detail Page and Edit Page option in section properties.... I added Account fields and section header fields in page layout.... I view the page " header Section names not display in the view page" but I am editing  the page the header section names are displayed... Can I possible to display section header names in view page?

I have used Standard set controller to query the accounts object.... Accounts object have more than 4000 records..... i am passing the list to page the standard set controller pass only 2000 records....if any possible to pass all 4000 records to my visual force page....????????