function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sascha DeinertSascha Deinert 

RIGHT(String s, Ingeter i)

Hi,

I create a right method, but how can I use the s variable for the insert into the stats object?

Thanks,
Sascha
 
public class Stats_class {

public Stats_class() {
}

Public String Right(String s, Integer I) {
S = ApexPages.currentPage().getUrl();
I = 15;

return s;
}

public pagereference dmlop() {

    Stats__c sta = new Stats__c();
    sta.User__c = Userinfo.getUserId();    
    sta.Site__c = ApexPages.currentPage().getUrl();
    INSERT sta;
    RETURN NULL;
}

}

 
Abhishek BansalAbhishek Bansal
Hi Sascha,

I have modified your code according to your requirement.
Please use the below updated code :
public class Stats_class {

public Stats_class() {
}

Public String Right() {
S = ApexPages.currentPage().getUrl();
I = 15;//Dont know why it is used

return s;
}

public pagereference dmlop() {

    Stats__c sta = new Stats__c();
    sta.User__c = Userinfo.getUserId();    
    sta.Site__c = Right();//This will assign the value of s returned from right method 
    INSERT sta;
    RETURN NULL;
}

}

Let me know if you need more information or help on this.

Thanks,
Abhishek Bansal