0

Error: Compile Error: Method does not exist or incorrect signature: void ceiling(Integer) from the type System.Math at line 19 column 36

Trying to add an integer for week of the year into class ?

any assistance would be great

public class AddingChildControllerv2 {
    Id parentId;
    public List<Time_Sheets__c> childList {get;set;}
    public Integer rowNum{get;set;}

    public Pay_Run__c Parent {get;set;}


    public Integer weekOfYear {get; set;}


    public AddingChildControllerv2(){
        Id childId = ApexPages.currentPage().getParameters().get('childId');
        childList = new List<Time_Sheets__c>();
        childList.add(new Time_Sheets__c());
        ParentId=ApexPages.currentPage().getParameters().get('ParentId');  

        Integer dayOfYear = Date.today().dayOfYear();
            weekOfYear = Math.mod(Math.ceiling(dayOfYear / 7), 52) + 1;

    }

    public pagereference insertChild(){
        insert childList;

        Pagereference parentPage;
        if(!childList.isEmpty() && !string.isBlank(childList[0].Pay_Run__c))
            parentPage=new pagereference('/'+childList[0].Pay_Run__c);
        return parentPage;

    }    

    public void insertRow(){
        childList.add(new Time_Sheets__c());

    }

    public void delRow(){
        rowNum = 
    Integer.valueof(apexpages.currentpage().getparameters().get('index'));

    childList.remove(rowNum);
    }
}

screenshot

0

Apex class has ceil method. You have a typo. Please refer below URL for more details

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_math.htm

0

i found two issues in your code based on error message, there is no ceiling method in System.Math class, you should use ceil instead of celing then you have to convert Decimal to Integer, working code.

Integer dayOfYear = Date.today().dayOfYear();
  Decimal weekOfYear = Math.mod(Integer.valueof(Math.ceil(dayOfYear / 7)), 52) + 1;
System.debug('weekOfYear' + weekOfYear);  // 08:24:36:007 USER_DEBUG [3]|DEBUG|weekOfYear40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.