Formula field

Posted by Paulh0763 on 11-Aug-2015 08:12

Is it possible to create a formula field that returns the results of the checkboxes that are unchecked from a group of checkbox field? Not sure if this is possible? Any assistance is appreciated. Basically, I have a group of checkbox field called paperwork received and I want a formula field to return only what was not received. Thanks Big Smile

All Replies

Posted by Karthikeyan Bhaskaran on 17-Aug-2015 01:27

You can use Javascript to traverse the checkbox items and return the ones that are not checked.

Formula Field has a return value and hence all the unchecked items should be part of the single return.

Another approach: set an initial / default value to the checkbox and work out a solution around these default values.

Posted by Paulh0763 on 17-Aug-2015 06:55

I can get the formula field to return the checked values from the group of checkbox field but not the unchecked values. This is what I am using to return the checked values.

rbv_api.selectValue("SELECT paperwork_received#value FROM Customer_Implementation WHERE id = {!id}");

Posted by Mohammed Siraj on 17-Aug-2015 07:20

As suggested by Karthikeyan above, since Formula field does not have an Array return type, you need to return all item (unchecked) values concatenated as a string with some seperator say ','.

Now to compute the set of unchecked values, you can leverage the following two api's:

rbv_api.getpicklist() - This will return all items in CheckBoxGroup.

rbv_api.getFieldValue() - The set of checked items. OR Token for this field.

Posted by Paulh0763 on 17-Aug-2015 07:36

Hello msiraj,

Thanks for the additional input but the rbv_api.getPicklist is returning the checked items only and is not returning all items in the group of checkbox field. Both api's are returning the same data. My coding is not the best, can you provide a better example I can work off of? I do appreciate your assistance.

Thanks

Posted by Mohammed Siraj on 17-Aug-2015 10:17

Have just tried it out. Seems to be working fine. 

Am sharing a code snippet for your requirement, hope this will help.

var allItems = rbv_api.getPicklist('testPicklistCode', 'testCB123',-1);

var selItems = "{!testCB123#value}";

//for debugging -- selected values
rbv_api.println("Selected Values - "+selItems);

var selItemsArr = selItems.split(',');

for(var i=0;i<selItemsArr.length;i++){
selItemsArrIdea = selItemsArrIdea.trim();
}

var notSelItemsArr = [];

rbv_api.println("\nList of all values - ");
for(var j=0;j<allItems.length;j++){
var item = allItems[j];
rbv_api.println(item.name);
if(item && !(selItemsArr.indexOf(item.name) > -1)){
notSelItemsArr.push(item && item.name);
}

}

return notSelItemsArr.join(',');

Change the following values in the above code snippet - 

Obj Name from Object Definition Page - 'testPicklistCode'

Field Integration Name for CheckBoxGroup field - 'testCB123'

Posted by Mohammed Siraj on 17-Aug-2015 10:20

Reposting some part of code that was wrongly transformed:

for(var i=0;i<selItemsArr.length;i++){

selItemsArr[ i ] = selItemsArr[ i ].trim();

}

Posted by Paulh0763 on 17-Aug-2015 11:00

Thanks so much!! I really appreciate your assistance. I am getting this error though:

Error  Cannot find function getPicklist in object com.rb.core.services.api.ServerSideAPI@44f619c4. (line #4) in formula:

var rbv_api = new Packages.com.rb.core.services.api.ServerSideAPI(13924598, 15897973);

function wrapper() {

var allItems = rbv_api.getPicklist('Customer_Implementation', 42188108, 'paperwork_received', -1)

var selItems = "8655, DD Plus (NatPay) Authorization Form, DD Plus EIN/TIN Attestation (if n...

This is my code (updated per suggested):

var allItems = rbv_api.getPicklist('Customer_Implementation', {!id}, 'paperwork_received', -1)

var selItems = "{!paperwork_received#value}";

//for debugging -- selected values

rbv_api.println("Selected Values - "+selItems);

var selItemsArr = selItems.split(',');

for(var i=0; i < selItemsArr.length; i++){

selItemsArrIdea = selItemsArrIdea.trim();

}

var notSelItemsArr = [];

rbv_api.println("\nList of all values - ");

for(var j=0; j < allItems.length; j++){

var item = allItems[j];

rbv_api.println(item.name);

if(item && !(selItemsArr.indexOf(item.name) > -1)){

notSelItemsArr.push(item && item.name);

}

}

return notSelItemsArr.join(',');

Posted by Paulh0763 on 17-Aug-2015 11:18

update this is what I am using:

var allItems = rbv_api.getPicklist('Customer_Implementation',  'paperwork_received', -1)

Posted by Paulh0763 on 17-Aug-2015 12:37

I am thinking maybe this is because I am on release 2.2.2.0 soon to be update before end of year to version 3.2.3

Posted by Mohammed Siraj on 17-Aug-2015 13:58

Yes, that explains it.

rbv_api.getPicklist was introduced in release 3.2.

Posted by Paulh0763 on 17-Aug-2015 14:03

Just what I thought. So now I have cloned that group of checkbox field and made all the default values to be checked. Now I am trying to compare them to get the unchecked values. :)

Posted by Anoop Premachandran on 18-Aug-2015 04:08

3.2.4 is latest build. Soon we are going to release 4.0.0

Posted by Paulh0763 on 25-Aug-2015 07:12

Hello Anoop,

Can you envision another approach on how I could do this? I might be going about this the wrong way but what I have done to get these 'unchecked checkbox values' is to create separate formula fields to return the value if false. (Example: "{!_2848#value}" == "false" ? 2848 : null; ) Then I created a template text field to bring the tokens in if they are false and display them on my email template in a listview (Example: <span style='color:#000000; font-weight:bold;'>{!formula_2848#value}</span> <br> However, this approach leaves gaps and spaces if the formula field(s) are true and not false, so the list would look like the following below:

false1

false2

GAP BECAUSE VALUE IS TRUE

false3

false4

false5

GAP BECAUSE VALUE IS TRUE

GAP BECAUSE VALUE IS TRUE

GAP BECAUSE VALUE IS TRUE

false6

I hope this makes sense logically for you to assist? I need to know if I use this approach how can I eliminate the gaps? I even tried separated by comma but then I get:

false1 false2, , false3, false4, false5, , , , false6

Thanks as always for your help! Big Smile

This thread is closed