You need to sign in to do that
Don't have an account?
Rick MacGuigan
Convert negative number to positive
This should be simple but appears difficult. My visual force page displays negative values retrieved from SOQL query in the controller. I need that number to be positive and thought I could simply use ABS to do this on either the VisualdForce page or controller.
How can I do this ? field is PAID_LOSS__c
VF Page:
How can I do this ? field is PAID_LOSS__c
VF Page:
<apex:dataTable id="dt2c" styleClass="alldatatables" headerClass="alldatacols" columnClasses="alldatacols" rowClasses="alldatarows" value="{!PriorYRcontractSectionList}" var="pyr" rules="all" cellpadding="5" > ... <apex:column value="{!pyr.PAID_LOSS__c}" headerValue="Ttl Rprd Loss" rendered="{! (allNulls_PAID_LOSS_dt2c || hidecols) }"/>Controller:
private List<MR_Contracts__c> queryPriorYRcontractsectionById(List<String> contractIds, string ContractYear) { //used to display Contract Section Data based on user selected submissions for the multiselect field. //Filter by List<MR_Contracts__c> PriorYRcontractsectionById = [ //return [ SELECT Id ,Name ,ULTIMATE_PREMIUM__c ,PAID_LOSS__c ,ACR__c ,ULTIMATE_LOSS__c ,Ultimate_Loss_Ratio__c ,F_DETAIL_COMMISSION__c ,F_DETAIL_BROKERAGE__c ,ULT_OVERHEAD_EXCL_CATS__c ,ULT_CR_ACCT_OH__c ,ULT_CR_ACCT_EXCL_OH__c ,ITD_CR_INCL_ACCT_OH__c ,ITD_CR_EXCL_ACCT_OH__c FROM MR_Contracts__c WHERE ContractSubmissionRef__c IN :contractIds ORDER BY Name DESC ]; this.allNulls_PAID_LOSS_dt2c= false; this.allNulls_ACR_dt2c= false; this.allNulls_ULTIMATE_LOSS_dt2c= false; this.allNulls_Ultimate_Loss_Ratio_dt2c= false; this.allNulls_F_DETAIL_COMMISSION_dt2c= false; this.allNulls_F_DETAIL_BROKERAGE_dt2c= false; this.allNulls_ULT_OVERHEAD_EXCL_CATS_dt2c= false; this.allNulls_ULT_CR_ACCT_OH_dt2c= false; this.allNulls_ULT_CR_ACCT_EXCL_OH_dt2c= false; this.allNulls_ITD_CR_INCL_ACCT_OH_dt2c= false; this.allNulls_ITD_CR_EXCL_ACCT_OH_dt2c= false; for (MR_Contracts__c dt2cResult : PriorYRcontractsectionById) { //special considerations: Need to summ up all column values and test if total <- 0 to ensure all columns contain no data. Used to render column in dataTables. if (dt2cResult.PAID_LOSS__c > 0) {allNulls_PAID_LOSS_dt2c = true;} if (dt2cResult.ACR__c > 0) {allNulls_ACR_dt2c = true;} if (dt2cResult.ULTIMATE_LOSS__c > 0) {allNulls_ULTIMATE_LOSS_dt2c = true;} if (dt2cResult.Ultimate_Loss_Ratio__c > 0) {allNulls_Ultimate_Loss_Ratio_dt2c = true;} if (dt2cResult.F_DETAIL_COMMISSION__c > 0) {allNulls_F_DETAIL_COMMISSION_dt2c = true;} if (dt2cResult.F_DETAIL_BROKERAGE__c > 0) {allNulls_F_DETAIL_BROKERAGE_dt2c = true;} if (dt2cResult.ULT_OVERHEAD_EXCL_CATS__c > 0) {allNulls_ULT_OVERHEAD_EXCL_CATS_dt2c = true;} if (dt2cResult.ULT_CR_ACCT_OH__c > 0) {allNulls_ULT_CR_ACCT_OH_dt2c = true;} if (dt2cResult.ULT_CR_ACCT_EXCL_OH__c > 0) {allNulls_ULT_CR_ACCT_EXCL_OH_dt2c = true;} if (dt2cResult.ITD_CR_INCL_ACCT_OH__c > 0) {allNulls_ITD_CR_INCL_ACCT_OH_dt2c = true;} if (dt2cResult.ITD_CR_EXCL_ACCT_OH__c > 0) {allNulls_ITD_CR_EXCL_ACCT_OH_dt2c = true;} } return PriorYRcontractsectionById; }
All Answers
Try with below code for VF page. It will do the trick :)
Thanks,
Amit Singh.
Syntax error. Missing ')'
Error is in expression '{!ABS(pyr}' in component <apex:dataTable> in page prod_uw_accountsummary
Error: Syntax error. Missing ')'
Try below code and make Sure PAID_LOSS__c is Number filed. Hope this will help. Let me know :)
Thanks,
Amit Singh.
Using the outputText embedded in the column oriduces a positve number that lack the thousand seperator. Why can't I use the ABS function in the value instead of having to output it as text. This field type is a double.
related code: