Forum Discussion

Re: javascript to get count of multi-select choices

There might be a cleaner way of XML parsing - but you can do something like this to make the call using a $.get and then parse the XML response and dig a little to get the choice count: 

var text field = URLRoot() & "db/" & [_DBID_REQUESTS] & "?a=API_GetFieldProperties&fid=9";

"javascript: {" & 
  "$.get('" & $urlD & "',function(data,success) {" & 
        "var count = data.getElementsByTagName('field')[0].getElementsByTagName('choices')[0].children.length);" &
       "$.get('" & URLRoot() & "db/" & [_DBID_REQUESTS] & "?a=API_EditRecord&rid=" & [Record ID#] & "&_fid_10='" + count);"
  "});" &   
"}"

In this example - you would do an Edit Recod call to store the value in the number of field choices - I put fid 10 for demo

Chayce Duncan | Director of Strategic Solutions
(720) 739-1406 | chayceduncan@quandarycg.com
Quandary Knowledge Base
No RepliesBe the first to reply