Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- //get person id from querystring
- var person = getQueryVariable('rid');
- //clean up matrix items without related skills
- var url = 'bmzta34wf?a=API_PurgeRecords&query={6.EX.}&apptoken=bh89wwc8sxc9ac2g83fme83nsi';
- var promise = $.get(url);
- //clean up matrix items without related people
- url = 'bmzta34wf?a=API_PurgeRecords&query={31.EX.}&apptoken=bh89wwc8sxc9ac2g83fme83nsi';
- promise = $.get(url);
- //get all skills from Skills table
- url = 'bmzizdnpr?a=API_DoQuery&clist=a&apptoken=bh89wwc8sxc9ac2g83fme83nsi';
- promise = $.get(url);
- $.when(promise).then(function(xml) {
- //loop through skills
- $(xml).find('record').each(function() {
- //get skill id
- var skill = $(this).find("record_id_").text();
- //check for existing combination of skill and person on 'SKills List' table
- var url = 'bmzta34wf?act=API_DoQueryCount&clist=a&query={6.EX.' + skill + '}AND{31.EX.' + person + '}&apptoken=bh89wwc8sxc9ac2g83fme83nsi';
- var promise = $.get(url);
- $.when(promise).then(function(xml) {
- $(xml).find('qdbapi').each(function() {
- //check if an item with the skill x person combination already exists
- var matches = $(this).find('numMatches').text();
- //if it does not exist, create it
- if (matches == 0) {
- var url = 'bmzta34wf?act=API_AddRecord&clist=a&_fid_6=' + skill + '&_fid_31=' + person + '&apptoken=bh89wwc8sxc9ac2g83fme83nsi';
- var promise = $.get(url);
- }
- });
- });
- });
- })
- })
- //function to get querystring values from variables
- function getQueryVariable(variable) {
- var query = window.location.search.substring(1);
- var vars = query.split('&');
- for (var i = 0; i < vars.length; i++) {
- var pair = vars[i].split('=');
- if (pair[0] == variable) {
- return pair[1];
- }
- }
- return (false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement